set key with expire time

1,957 views
Skip to first unread message

Christopher Gokey

unread,
Feb 19, 2016, 1:48:02 PM2/19/16
to lettuce-redis-client-users
I'm really liking redis the more that I get into it.    

Question.
Right now, I'm using:
connection.set(key, value);

I noticed that a third argument can be added, SetArgs....

Trying to find documentation that will allow me to set an expire timestamp at the time of the set, my guess is it is SetArgs, how would i use this?   

SetArgs args = SetArgs.ex(60*60)); // set for 60 minutes

It isn't possible to auto expire keys at a certain value is there?

Thanks,
Chris

Mark Paluch

unread,
Feb 19, 2016, 1:59:36 PM2/19/16
to Christopher Gokey, lettuce-redis-client-users
Hi Chris, 
glad to hear that.

lettuce is a low-level Redis driver that uses the same command terminology as Redis does. The set command in particular is documented here [0] and you can use [1] px (milliseconds) or ex(seconds) as expiry values. You can find a lot of details on your questions within the Redis docs [2].

There are also Redis clients which provide an API on a higher abstraction level [3] [4] [5]. Those libraries allow object mapping or annotation-driven expiry configuration.

Cheers, Mark


--
You received this message because you are subscribed to the Google Groups "lettuce-redis-client-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lettuce-redis-clien...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lettuce-redis-client-users/ef4b31ff-963b-41c9-a98c-4086ae5c3e10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christopher Gokey

unread,
Feb 19, 2016, 2:10:04 PM2/19/16
to Mark Paluch, lettuce-redis-client-users
Thank you Mark!  
Chris
Reply all
Reply to author
Forward
0 new messages