Class: Handlers::ActiveSupportCacheStoreHandler

Inherits:
Handler
  • Object
show all
Defined in:
lib/handlers/active_support_cache_store_handler.rb

Instance Method Summary collapse

Methods inherited from Handler

cache_class

Constructor Details

#initialize(object = nil) ⇒ ActiveSupportCacheStoreHandler



4
5
6
7
# File 'lib/handlers/active_support_cache_store_handler.rb', line 4

def initialize(object=nil)
  raise "Must provide an existing ActiveSupport::Cache::Store" unless object.is_a?(ActiveSupport::Cache::Store)
  @cache = object
end

Instance Method Details

#get(key) ⇒ Object



13
14
15
# File 'lib/handlers/active_support_cache_store_handler.rb', line 13

def get(key)
  @cache.read(key)
end

#increment(key) ⇒ Object



9
10
11
# File 'lib/handlers/active_support_cache_store_handler.rb', line 9

def increment(key)
  @cache.write(key, (get(key)||0).to_i+1)
end