Module: Sequel::Plugins::Caching::ClassMethods

Defined in:
lib/sequel/plugins/caching.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cache_ignore_exceptionsObject (readonly)

If true, ignores exceptions when gettings cached records (the memcached API).



47
48
49
# File 'lib/sequel/plugins/caching.rb', line 47

def cache_ignore_exceptions
  @cache_ignore_exceptions
end

#cache_storeObject (readonly)

The cache store object for the model, which should implement the Ruby-Memcache (or memcached) API



51
52
53
# File 'lib/sequel/plugins/caching.rb', line 51

def cache_store
  @cache_store
end

#cache_ttlObject (readonly)

The time to live for the cache store, in seconds.



54
55
56
# File 'lib/sequel/plugins/caching.rb', line 54

def cache_ttl
  @cache_ttl
end

Instance Method Details

#inherited(subclass) ⇒ Object

Copy the necessary class instance variables to the subclass.



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/sequel/plugins/caching.rb', line 62

def inherited(subclass)
  super
  store = @cache_store
  ttl = @cache_ttl
  cache_ignore_exceptions = @cache_ignore_exceptions
  subclass.instance_eval do
    @cache_store = store
    @cache_ttl = ttl
    @cache_ignore_exceptions = cache_ignore_exceptions
  end
end

#set_cache_ttl(ttl) ⇒ Object

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



57
58
59
# File 'lib/sequel/plugins/caching.rb', line 57

def set_cache_ttl(ttl)
  @cache_ttl = ttl
end