Module: Card::Cache::PersistentClass

Included in:
Persistent
Defined in:
card/lib/card/cache/persistent_class.rb

Overview

class methods for Card::Cache::Persistent

Instance Method Summary collapse

Instance Method Details

#new_stampObject

stamp generator



10
11
12
# File 'card/lib/card/cache/persistent_class.rb', line 10

def new_stamp
  Time.now.to_i.to_s(36) + rand(999).to_s(36)
end

#renewObject



18
19
20
# File 'card/lib/card/cache/persistent_class.rb', line 18

def renew
  @stamp = nil
end

#resetObject



22
23
24
25
# File 'card/lib/card/cache/persistent_class.rb', line 22

def reset
  @stamp = new_stamp
  Cardio.cache.write stamp_key, @stamp
end

#stampObject



5
6
7
# File 'card/lib/card/cache/persistent_class.rb', line 5

def stamp
  @stamp ||= Cardio.cache.fetch(stamp_key) { new_stamp }
end

#stamp_keyObject



14
15
16
# File 'card/lib/card/cache/persistent_class.rb', line 14

def stamp_key
  "#{Cardio.database_name}-stamp"
end