Class: Flareshow::Cache
- Inherits:
-
Object
- Object
- Flareshow::Cache
- Defined in:
- lib/cache.rb
Overview
a simple in memory cache for Flareshow objects
Instance Method Summary collapse
-
#flush ⇒ Object
remove all cached objects.
-
#get_resource(resource_key, id) ⇒ Object
load a resource from the cache.
-
#set_resource(resource_key, id, object) ⇒ Object
set a resource in the cache.
-
#size ⇒ Object
number of cached objects.
Instance Method Details
#flush ⇒ Object
remove all cached objects
51 52 53 |
# File 'lib/cache.rb', line 51 def flush data = {} end |
#get_resource(resource_key, id) ⇒ Object
load a resource from the cache
41 42 43 |
# File 'lib/cache.rb', line 41 def get_resource(resource_key, id) resource_cache(resource_key)[id] end |
#set_resource(resource_key, id, object) ⇒ Object
set a resource in the cache
46 47 48 |
# File 'lib/cache.rb', line 46 def set_resource(resource_key, id, object) resource_cache(resource_key)[id] = object end |
#size ⇒ Object
number of cached objects
56 57 58 |
# File 'lib/cache.rb', line 56 def size data.values.inject(0){|m,v| m+=v.size} end |