Class: MyStuff::Cache::MemoryCache
- Defined in:
- lib/my_stuff/cache/memory_cache.rb
Overview
Hash-based cache.
This will not be shared between instances of the cache - for example, this means that it won’t be shared between all requests in a Passenger or pool-based setup.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #get(keys, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ MemoryCache
constructor
A new instance of MemoryCache.
- #set(values, options = {}) ⇒ Object
Methods inherited from Base
#get_with_fallback, #get_with_multi_fallback
Constructor Details
#initialize(options = {}) ⇒ MemoryCache
Returns a new instance of MemoryCache.
11 12 13 14 |
# File 'lib/my_stuff/cache/memory_cache.rb', line 11 def initialize = {} @cache = Hash.new super end |
Instance Method Details
#get(keys, options = {}) ⇒ Object
16 17 18 |
# File 'lib/my_stuff/cache/memory_cache.rb', line 16 def get keys, = {} keys.map{|key| @cache[key]} end |
#set(values, options = {}) ⇒ Object
20 21 22 |
# File 'lib/my_stuff/cache/memory_cache.rb', line 20 def set values, = {} @cache.merge! values end |