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
-
#delete_resource(resource_key, id) ⇒ Object
remove a resource.
-
#flush ⇒ Object
remove all cached objects.
-
#get_resource(resource_key, id) ⇒ Object
load a resource from the cache.
- #list_resource(resource_key) ⇒ Object
-
#set_resource(resource_key, id, object) ⇒ Object
set a resource in the cache.
-
#size ⇒ Object
number of cached objects.
Instance Method Details
#delete_resource(resource_key, id) ⇒ Object
remove a resource
62 63 64 |
# File 'lib/cache.rb', line 62 def delete_resource(resource_key, id) resource_cache(resource_key).delete(id) end |
#flush ⇒ Object
remove all cached objects
71 72 73 |
# File 'lib/cache.rb', line 71 def flush data = {} end |
#get_resource(resource_key, id) ⇒ Object
load a resource from the cache
52 53 54 |
# File 'lib/cache.rb', line 52 def get_resource(resource_key, id) resource_cache(resource_key)[id] end |
#list_resource(resource_key) ⇒ Object
66 67 68 |
# File 'lib/cache.rb', line 66 def list_resource(resource_key) resource_cache(resource_key) end |
#set_resource(resource_key, id, object) ⇒ Object
set a resource in the cache
57 58 59 |
# File 'lib/cache.rb', line 57 def set_resource(resource_key, id, object) resource_cache(resource_key)[id] = object end |
#size ⇒ Object
number of cached objects
76 77 78 |
# File 'lib/cache.rb', line 76 def size data.values.inject(0){|m,v| m+=v.size} end |