Class: GirlFriday::Store::Redis
- Inherits:
-
Object
- Object
- GirlFriday::Store::Redis
- Defined in:
- lib/girl_friday/persistence.rb
Instance Method Summary collapse
-
#initialize(name, options) ⇒ Redis
constructor
A new instance of Redis.
- #pop ⇒ Object
- #push(work) ⇒ Object (also: #<<)
- #size ⇒ Object
Constructor Details
#initialize(name, options) ⇒ Redis
Returns a new instance of Redis.
24 25 26 27 28 |
# File 'lib/girl_friday/persistence.rb', line 24 def initialize(name, ) @opts = raise ArgumentError, "you must pass in a :pool" unless @opts[:pool] @key = "girl_friday-#{name}-#{environment}" end |
Instance Method Details
#pop ⇒ Object
36 37 38 39 |
# File 'lib/girl_friday/persistence.rb', line 36 def pop val = redis { |r| r.lpop(@key) } Marshal.load(val) if val end |
#push(work) ⇒ Object Also known as: <<
30 31 32 33 |
# File 'lib/girl_friday/persistence.rb', line 30 def push(work) val = Marshal.dump(work) redis { |r| r.rpush(@key, val) } end |
#size ⇒ Object
41 42 43 |
# File 'lib/girl_friday/persistence.rb', line 41 def size redis { |r| r.llen(@key) } end |