Class: MyStuff::Cache::MemoryCache

Inherits:
Base
  • Object
show all
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

#logger

Instance Method Summary collapse

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 options = {}
  @cache = Hash.new
  super options
end

Instance Method Details

#get(keys, options = {}) ⇒ Object



16
17
18
# File 'lib/my_stuff/cache/memory_cache.rb', line 16

def get keys, options = {}
  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, options = {}
  @cache.merge! values
end