lib/suo/client/redis.rb in suo-0.3.2 vs lib/suo/client/redis.rb in suo-0.3.3
- old
+ new
@@ -16,13 +16,17 @@
def get
[@client.get(@key), nil]
end
- def set(newval, _)
+ def set(newval, _, expire: false)
ret = @client.multi do |multi|
- multi.set(@key, newval)
+ if expire
+ multi.setex(@key, @options[:ttl], newval)
+ else
+ multi.set(@key, newval)
+ end
end
ret && ret[0] == OK_STR
end
@@ -33,10 +37,11 @@
ensure
@client.unwatch
end
def initial_set(val = BLANK_STR)
- @client.set(@key, val)
+ set(val, nil)
+ nil
end
end
end
end