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

Sequel‘s built-in caching plugin supports caching to any object that implements the Ruby-Memcache API. You can add caching for any model or for all models via:

      Model.plugin :caching, store   # Cache all models
      MyModel.plugin :caching, store # Just cache MyModel

The cache store should implement the Ruby-Memcache API:

       cache_store.set(key, obj, time) # Associate the obj with the given key
                                       # in the cache for the time (specified
                                       # in seconds)
       cache_store.get(key) => obj # Returns object set with same key
       cache_store.get(key2) => nil # nil returned if there isn't an object
                                    # currently in the cache with that key

### Methods

apply

### Classes and Modules

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

### Public Class methods

apply(model, store, opts={})

Set the cache_store and cache_ttl attributes for the given model. If the :ttl option is not given, 3600 seconds is the default.

[Source]

        # File lib/sequel/plugins/caching.rb, line 21
    21:       def self.apply(model, store, opts={})
    22:         model.instance_eval do
    23:           @cache_store = store
    24:           @cache_ttl = opts[:ttl] || 3600
    25:         end
    26:       end

[Validate]