Class: Handlers::ActiveSupportCacheStoreHandler
- Defined in:
- lib/handlers/active_support_cache_store_handler.rb
Instance Method Summary collapse
- #get(key) ⇒ Object
- #increment(key) ⇒ Object
-
#initialize(object = nil) ⇒ ActiveSupportCacheStoreHandler
constructor
A new instance of ActiveSupportCacheStoreHandler.
Methods inherited from Handler
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 |