Class: GirlFriday::Store::Redis

Inherits:
Object
  • Object
show all
Defined in:
lib/girl_friday/persistence.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ Redis

Returns a new instance of Redis.

Raises:

  • (ArgumentError)


24
25
26
27
28
# File 'lib/girl_friday/persistence.rb', line 24

def initialize(name, options)
  @opts = options
  raise ArgumentError, "you must pass in a :pool" unless @opts[:pool]
  @key = "girl_friday-#{name}-#{environment}"
end

Instance Method Details

#popObject



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

#sizeObject



41
42
43
# File 'lib/girl_friday/persistence.rb', line 41

def size
  redis { |r| r.llen(@key) }
end