File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,18 @@ limiter.poke # => SET limiter 0 NX + INCRBY limiter 1
177177false == limiter.exceeded? # => GET "limiter"
178178```
179179
180+ Lists, unique lists, sets, and ordered sets support expiration:
181+
182+ ``` ruby
183+ set = Kredis .set " myset" , expires_in: 1 .second
184+ set.add " hello" , " world" # => SADD myset "hello" "world"
185+ true == set.include?(" hello" ) # => SISMEMBER myset "hello
186+ sleep 2
187+ [] == set.members # => SMEMBERS myset
188+ ```
189+
190+ To support lower versions of redis, which does not has ` nx ` option on ` EXPIRE ` command, multiple commands are used to achieve the same effect.
191+
180192### Models
181193
182194You can use all these structures in models:
@@ -189,6 +201,7 @@ class Person < ApplicationRecord
189201 kredis_unique_list :skills , limit: 2
190202 kredis_enum :morning , values: %w[ bright blue black ] , default: " bright"
191203 kredis_counter :steps , expires_in: 1 .hour
204+ kredis_set :favorite_colors , expires_in: 1 .day
192205
193206 private
194207 def generate_names_key
You can’t perform that action at this time.
0 commit comments