File tree 1 file changed +13
-0
lines changed 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
177
177
false == limiter.exceeded? # => GET "limiter"
178
178
```
179
179
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
+
180
192
### Models
181
193
182
194
You can use all these structures in models:
@@ -189,6 +201,7 @@ class Person < ApplicationRecord
189
201
kredis_unique_list :skills , limit: 2
190
202
kredis_enum :morning , values: %w[ bright blue black ] , default: " bright"
191
203
kredis_counter :steps , expires_in: 1 .hour
204
+ kredis_set :favorite_colors , expires_in: 1 .day
192
205
193
206
private
194
207
def generate_names_key
You can’t perform that action at this time.
0 commit comments