Class: RedisEnv::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/redis_env/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#redisObject (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

#clearObject



25
26
27
# File 'lib/redis_env/client.rb', line 25

def clear
  redis.del(namespace)
end

#namespaceObject



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

#variablesObject



9
10
11
# File 'lib/redis_env/client.rb', line 9

def variables
  redis.hgetall(namespace)
end