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.



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

def initialize(name, options)
  @opts = options
  @key = "girl_friday-#{name}-#{environment}"
end

Instance Method Details

#popObject



35
36
37
38
# File 'lib/girl_friday/persistence.rb', line 35

def pop
  val = redis.lpop(@key)
  Marshal.load(val) if val
end

#push(work) ⇒ Object Also known as: <<



29
30
31
32
# File 'lib/girl_friday/persistence.rb', line 29

def push(work)
  val = Marshal.dump(work)
  redis.rpush(@key, val)
end

#sizeObject



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

def size
  redis.llen(@key)
end