Module | Sequel::Plugins::Caching::ClassMethods |
In: |
lib/sequel/plugins/caching.rb
|
cache_ignore_exceptions | [R] | If true, ignores exceptions when gettings cached records (the memcached API). |
cache_store | [R] | The cache store object for the model, which should implement the Ruby-Memcache (or memcached) API |
cache_ttl | [R] | The time to live for the cache store, in seconds. |
Delete the cached object with the given primary key.
# File lib/sequel/plugins/caching.rb, line 57 57: def cache_delete_pk(pk) 58: cache_delete(cache_key(pk)) 59: end
Return the cached object with the given primary key, or nil if no such object is in the cache.
# File lib/sequel/plugins/caching.rb, line 63 63: def cache_get_pk(pk) 64: cache_get(cache_key(pk)) 65: end
Return a key string for the given primary key.
# File lib/sequel/plugins/caching.rb, line 68 68: def cache_key(pk) 69: raise(Error, 'no primary key for this record') unless pk.is_a?(Array) ? pk.all? : pk 70: "#{self}:#{Array(pk).join(',')}" 71: end
Copy the necessary class instance variables to the subclass.
# File lib/sequel/plugins/caching.rb, line 74 74: def inherited(subclass) 75: super 76: store = @cache_store 77: ttl = @cache_ttl 78: cache_ignore_exceptions = @cache_ignore_exceptions 79: subclass.instance_eval do 80: @cache_store = store 81: @cache_ttl = ttl 82: @cache_ignore_exceptions = cache_ignore_exceptions 83: end 84: end