Module | Sequel::Plugins::Caching::ClassMethods
In: | lib/sequel/plugins/caching.rb

### Methods

[] inherited set_cache_ttl

### Attributes

cache_store | [R] | The cache store object for the model, which should implement the Ruby-Memcache API
cache_ttl | [R] | The time to live for the cache store, in seconds.

### Public Instance methods

[](*args)

Check the cache before a database lookup unless a hash is supplied.

[Source]

        # File lib/sequel/plugins/caching.rb, line 37
    37:         def [](*args)
    38:           args = args.first if (args.size == 1)
    39:           return super(args) if args.is_a?(Hash)
    40:           ck = cache_key(args)
    41:           if obj = @cache_store.get(ck)
    42:             return obj
    43:           end
    44:           if obj = super(args)
    45:             @cache_store.set(ck, obj, @cache_ttl)
    46:           end
    47:           obj
    48:         end

inherited(subclass)

Copy the cache_store and cache_ttl to the subclass.

[Source]

        # File lib/sequel/plugins/caching.rb, line 56
    56:         def inherited(subclass)
    57:           super
    58:           store = @cache_store
    59:           ttl = @cache_ttl
    60:           subclass.instance_eval do
    61:             @cache_store = store
    62:             @cache_ttl = ttl
    63:           end
    64:         end

set_cache_ttl(ttl)

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

[Source]

        # File lib/sequel/plugins/caching.rb, line 51
    51:         def set_cache_ttl(ttl)
    52:           @cache_ttl = ttl
    53:         end

[Validate]