module Sequel::Plugins::Caching::ClassMethods

Attributes

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.

Public Instance Methods

cache_delete_pk(pk) click to toggle source

Delete the cached object with the given primary key.

   # File lib/sequel/plugins/caching.rb
67 def cache_delete_pk(pk)
68   cache_delete(cache_key(pk))
69 end
cache_get_pk(pk) click to toggle source

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
73 def cache_get_pk(pk)
74   cache_get(cache_key(pk))
75 end
cache_key(pk) click to toggle source

Return a key string for the given primary key.

   # File lib/sequel/plugins/caching.rb
83 def cache_key(pk)
84   raise(Error, 'no primary key for this record') unless pk.is_a?(Array) ? pk.all? : pk
85   "#{cache_key_prefix}:#{Array(pk).join(',')}"
86 end
cache_key_prefix() click to toggle source

Returns the prefix used to namespace this class in the cache.

   # File lib/sequel/plugins/caching.rb
78 def cache_key_prefix
79   to_s
80 end
set_cache_ttl(ttl) click to toggle source

Set the time to live for the cache store, in seconds (default is 3600, # so 1 hour).

   # File lib/sequel/plugins/caching.rb
91 def set_cache_ttl(ttl)
92   @cache_ttl = ttl
93 end