I want to make a session management, I will set the token to expire in 30 minutes, and if it is active, it will refresh. But I can't do it with one command. I have to run "get token" and "setex toekn 1800 xxx"
Is redis such an order to do it? if not, why not?
Comment From: itamarhaber
Hello @huangapple
Keep in mind that this issue tracker should be used for reporting bugs or proposing improvements to the Redis server. Questions should be directed to the community:
- /r/redis subreddit
- the mailing list
- the
redistag at StackOverflow - the irc channel #redis on freenode.
As for the question, while there is no such single Redis command, you can compose the GET and SETEX (or, even better, just use EXPIRE) with a Lua script (see EVAL) like this one:
local val = redis.call('GET', KEYS[1])
if val ~= nil then
redis.call('EXPIRE', KEYS[1], 1800)
end
return val
Comment From: madolson
I suppose this was solved by the new getex command, so this can be resolved.