Module: Glue::Cacheable
- Defined in:
- lib/glue/cacheable.rb
Overview
Include this module in your Og managed classes to make them cacheable. Only queries by id are cached.
If you use a distributed cache (drb, memcache, etc) , you may have to start a separate server.
– gmosx, WARNING: If the file lib/og/entity.rb is changed this file should be updated to reflect the changes! ++
Class Method Summary collapse
-
.cache_delete(klass, pk) ⇒ Object
Invalidate the cache entry for an object.
-
.cache_get(klass, pk) ⇒ Object
…
-
.cache_set(obj) ⇒ Object
…
Class Method Details
.cache_delete(klass, pk) ⇒ Object
Invalidate the cache entry for an object. Og high level methods (for example the entity methods) automatically call this method where needed. However if you manually alter the store using Og low level methods (for example a native SQL query) you should call this method explicitly.
143 144 145 146 147 148 |
# File 'lib/glue/cacheable.rb', line 143 def self.cache_delete(klass, pk) #key = "og#{klass}:#{pk}" key = klass.og_cache_key(pk) # self.og_local_cache.delete(key) klass.ogmanager.cache.delete(key) end |
.cache_get(klass, pk) ⇒ Object
…
127 128 129 |
# File 'lib/glue/cacheable.rb', line 127 def self.cache_get(klass, pk) obj.class.ogmanager.cache.get(klass.og_cache_key(pk)) end |
.cache_set(obj) ⇒ Object
…
133 134 135 |
# File 'lib/glue/cacheable.rb', line 133 def self.cache_set(obj) obj.class.ogmanager.cache.set(obj.og_cache_key, obj) end |