Class: FeatureFlagger::Storage::Redis

Inherits:
Object
  • Object
show all
Defined in:
lib/feature_flagger/storage/redis.rb

Constant Summary collapse

DEFAULT_NAMESPACE =
:feature_flagger

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#redisObject


8
9
10
11
12
13
# File 'lib/feature_flagger/storage/redis.rb', line 8

def redis
  @redis ||= begin
    client = ::Redis.new(url: ENV['REDIS_URL'])
    ::Redis::Namespace.new(DEFAULT_NAMESPACE, redis: client)
  end
end

Instance Method Details

#add(key, value) ⇒ Object


19
20
21
# File 'lib/feature_flagger/storage/redis.rb', line 19

def add(key, value)
  redis.sadd(key, value)
end

#all_values(key) ⇒ Object


27
28
29
# File 'lib/feature_flagger/storage/redis.rb', line 27

def all_values(key)
  redis.smembers(key)
end

#has_value?(key, value) ⇒ Boolean

Returns:

  • (Boolean)

15
16
17
# File 'lib/feature_flagger/storage/redis.rb', line 15

def has_value?(key, value)
  redis.sismember(key, value)
end

#remove(key, value) ⇒ Object


23
24
25
# File 'lib/feature_flagger/storage/redis.rb', line 23

def remove(key, value)
  redis.srem(key, value)
end