lib/legion/cache/redis.rb in legion-cache-0.2.0 vs lib/legion/cache/redis.rb in legion-cache-0.2.1
- old
+ new
@@ -2,11 +2,11 @@
module Legion
module Cache
module Redis
def connect
- @client = Redis.new
+ @client = ::Redis.new
end
def close
@client.close
end
@@ -15,22 +15,25 @@
close
connect
end
def get(key)
- @client[key]
+ @client.get(key)
end
+ alias fetch get
- def set(key, value)
- @client[key] = value
+ def set(key, value, ttl: nil)
+ args = {}
+ args[:ex] = ttl unless ttl.nil?
+ @client.set(key, value, **args) == 'OK'
end
def delete(key)
- @client.del key
+ @client.del(key) == 1
end
def flush
- @client.flushdb
+ @client.flushdb == 'OK'
end
end
end
end