Class: RedisEnv::Client
- Inherits:
-
Object
- Object
- RedisEnv::Client
- Defined in:
- lib/redis_env/client.rb
Instance Attribute Summary collapse
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Instance Method Summary collapse
- #bulk_set(vars) ⇒ Object
- #clear ⇒ Object
-
#initialize(redis, project = nil) ⇒ Client
constructor
A new instance of Client.
- #namespace ⇒ Object
- #set(name, value) ⇒ Object
- #unset(name) ⇒ Object
- #variables ⇒ Object
Constructor Details
#initialize(redis, project = nil) ⇒ Client
Returns a new instance of Client.
4 5 6 7 |
# File 'lib/redis_env/client.rb', line 4 def initialize(redis, project=nil) @redis = redis @project = project || "__default__" end |
Instance Attribute Details
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
3 4 5 |
# File 'lib/redis_env/client.rb', line 3 def redis @redis end |
Instance Method Details
#bulk_set(vars) ⇒ Object
17 18 19 |
# File 'lib/redis_env/client.rb', line 17 def bulk_set(vars) redis.mapped_hmset(namespace, vars) end |
#clear ⇒ Object
25 26 27 |
# File 'lib/redis_env/client.rb', line 25 def clear redis.del(namespace) end |
#namespace ⇒ Object
29 30 31 |
# File 'lib/redis_env/client.rb', line 29 def namespace "redis-env:#{@project}" end |
#set(name, value) ⇒ Object
13 14 15 |
# File 'lib/redis_env/client.rb', line 13 def set(name, value) redis.hset(namespace, name, value) end |
#unset(name) ⇒ Object
21 22 23 |
# File 'lib/redis_env/client.rb', line 21 def unset(name) redis.hdel(namespace, name) end |
#variables ⇒ Object
9 10 11 |
# File 'lib/redis_env/client.rb', line 9 def variables redis.hgetall(namespace) end |