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 @@ -181,6 +181,18 @@ limiter.poke # => SET limiter 0 NX + INCRBY limiter 1
181181false == limiter.exceeded? # => GET "limiter"
182182```
183183
184+ Lists, unique lists, sets, and ordered sets support expiration:
185+
186+ ``` ruby
187+ set = Kredis .set " myset" , expires_in: 1 .second
188+ set.add " hello" , " world" # => SADD myset "hello" "world"
189+ true == set.include?(" hello" ) # => SISMEMBER myset "hello
190+ sleep 2
191+ [] == set.members # => SMEMBERS myset
192+ ```
193+
194+ To support lower versions of redis, which does not has ` nx ` option on ` EXPIRE ` command, multiple commands are used to achieve the same effect.
195+
184196### Models
185197
186198You can use all these structures in models:
@@ -193,6 +205,7 @@ class Person < ApplicationRecord
193205 kredis_unique_list :skills , limit: 2
194206 kredis_enum :morning , values: %w[ bright blue black ] , default: " bright"
195207 kredis_counter :steps , expires_in: 1 .hour
208+ kredis_set :favorite_colors , expires_in: 1 .day
196209
197210 private
198211 def generate_names_key
You can’t perform that action at this time.
0 commit comments