Class: Fib::Fpa

Inherits:
Object
  • Object
show all
Defined in:
lib/fib/fpa.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(redis = nil) ⇒ Fpa

Returns a new instance of Fpa.



6
7
8
# File 'lib/fib/fpa.rb', line 6

def initialize redis=nil
  @redis = redis
end

Instance Attribute Details

#redisObject

Returns the value of attribute redis.



4
5
6
# File 'lib/fib/fpa.rb', line 4

def redis
  @redis
end

Instance Method Details

#clear(redis_key) ⇒ Object



19
20
21
# File 'lib/fib/fpa.rb', line 19

def clear redis_key
  redis.del redis_key
end

#get(redis_key) ⇒ Object



14
15
16
17
# File 'lib/fib/fpa.rb', line 14

def get redis_key
  return nil unless redis.exists(redis_key)
  redis.smembers(redis_key).map(&:to_sym)
end

#save(redis_key, content) ⇒ Object



10
11
12
# File 'lib/fib/fpa.rb', line 10

def save redis_key, content
  redis.sadd redis_key, content
end