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.
142 143 144 145 146 147 |
# File 'lib/glue/cacheable.rb', line 142 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
…
126 127 128 |
# File 'lib/glue/cacheable.rb', line 126 def self.cache_get(klass, pk) obj.class.ogmanager.cache.get(klass.og_cache_key(pk)) end |
.cache_set(obj) ⇒ Object
…
132 133 134 |
# File 'lib/glue/cacheable.rb', line 132 def self.cache_set(obj) obj.class.ogmanager.cache.set(obj.og_cache_key, obj) end |