Class: Moneta::Cushion::Expiration

Inherits:
Object
  • Object
show all
Defined in:
lib/cushion/utils/moneta.rb

Instance Method Summary collapse

Constructor Details

#initialize(db) ⇒ Expiration

Returns a new instance of Expiration.



7
8
9
# File 'lib/cushion/utils/moneta.rb', line 7

def initialize(db)
  @db = db
end

Instance Method Details

#[](key) ⇒ Object



11
12
13
14
15
# File 'lib/cushion/utils/moneta.rb', line 11

def [](key)
  if obj = get(key)
    Time.parse(obj[:expires]) if obj[:expires]
  end
end

#[]=(key, value) ⇒ Object



17
18
19
20
21
# File 'lib/cushion/utils/moneta.rb', line 17

def []=(key, value)
  obj = get(key)
  obj[:expires] = value
  obj.save
end

#delete(key) ⇒ Object



23
24
25
26
27
# File 'lib/cushion/utils/moneta.rb', line 23

def delete(key)
  obj = get(key)
  obj[:expires] = nil
  obj.save
end