class Toggleable::RedisStore
Toggleable::RedisStore
is storage implementation using redis, you should specify namespace to use it. Also pass the redis instance used in when initializing.
Attributes
storage[RW]
Public Class Methods
new(redis_instance)
click to toggle source
# File lib/toggleable/storage/redis_store.rb, line 11 def initialize(redis_instance) @storage = redis_instance end
Public Instance Methods
get(key, namespace:)
click to toggle source
# File lib/toggleable/storage/redis_store.rb, line 15 def get(key, namespace:) storage.hget(namespace, key) end
get_all(namespace:)
click to toggle source
# File lib/toggleable/storage/redis_store.rb, line 19 def get_all(namespace:) storage.hgetall(namespace) end
mass_set(mappings, namespace:)
click to toggle source
# File lib/toggleable/storage/redis_store.rb, line 31 def mass_set(mappings, namespace:) mappings = mappings.flatten if mappings.is_a? Hash storage.hmset(namespace, mappings) end
set(key, value, namespace:)
click to toggle source
# File lib/toggleable/storage/redis_store.rb, line 23 def set(key, value, namespace:) storage.hset(namespace, key, value) end
set_if_not_exist(key, value, namespace:)
click to toggle source
# File lib/toggleable/storage/redis_store.rb, line 27 def set_if_not_exist(key, value, namespace:) storage.hsetnx(namespace, key, value) end