Use Redis to store some authentication information of active users to facilitate quick login. The user's information is of the hashes type, and the user's uid is used as the key. However, if the user has not logged in for a long time, it should be removed from Redis. I checked. The method I came across is to use the expire method of Jedis. I wrote a method myself, but I don’t know if it is correct.
public Long expire(String key, int time)
{
Jedis jedis = null;
Long rs;
try {
jedis = pool.getResource();
rs = jedis.expire(key, time);
return rs;
} catch (Exception e) {
e.printStackTrace();
return 0L;
} finally {
returnResource(jedis);
}
}
You will know if it is correct by trying it. What you need is not answers, you need encouragement.
What you lack is a verification tool. If you are familiar with Redis commands, you can use the command line
redis-cli
. If you are not familiar with it, you can use graphical tools, such asRedis Desktop Manager
Experiments are your best teachers, if you don’t see any problems when looking at the code
Thank you everyone, it’s OK. I installed a Linux virtual machine and tested it