class Snowden::Backends::RedisBackend
Attributes
namespace[R]
redis[R]
Public Class Methods
new(namespace="", redis=Redis.new(:driver => :hiredis))
click to toggle source
Creates a new redis backend
@param namespace [String] the string this backend is namespaced under. @param redis [Redis] a Redis object instance to talk to a redis database.
# File lib/snowden/backends/redis_backend.rb, line 11 def initialize(namespace="", redis=Redis.new(:driver => :hiredis)) @namespace = namespace @redis = redis end
Public Instance Methods
find(key)
click to toggle source
Finds a value in this index
@param key [String] the string key to search the index for. @return [ [String] ] a list of strings that matched the namespaced key.
# File lib/snowden/backends/redis_backend.rb, line 29 def find(key) redis.lrange(namespaced_key(key), 0, -1) end
save(key, value)
click to toggle source
Saves a value in this index
@param key [String] the string key to save the value under. @param value [String] the value to save.
# File lib/snowden/backends/redis_backend.rb, line 20 def save(key, value) redis.lpush(namespaced_key(key), value) nil end
Private Instance Methods
namespaced_key(key)
click to toggle source
# File lib/snowden/backends/redis_backend.rb, line 35 def namespaced_key(key) namespace + ":" + key end