class Crusade::GCM::InMemoryCache
Public Class Methods
cache()
click to toggle source
# File lib/crusade/gcm/cache/in_memory_cache.rb, line 18 def self.cache @cache ||= {} end
read(key)
click to toggle source
# File lib/crusade/gcm/cache/in_memory_cache.rb, line 6 def self.read(key) entry = cache.fetch(key) { {value: nil, valid_until: Time.now} } if entry[:valid_until] > Time.now entry[:value] end end
write(key, value, options = {})
click to toggle source
# File lib/crusade/gcm/cache/in_memory_cache.rb, line 13 def self.write(key, value, options = {}) expires_in = options.fetch(:expires_in) { 3600 } @cache[key] = { value: value, valid_until: (Time.now + expires_in) } end