Module: Sequel::Plugins::Cacheable

Defined in:
lib/sequel-cacheable/version.rb,
lib/sequel-cacheable/driver/dalli.rb,
lib/sequel-cacheable/driver/redis.rb,
lib/sequel-cacheable/class_methods.rb,
lib/sequel-cacheable/dataset_methods.rb,
lib/sequel-cacheable/driver/memcache.rb,
lib/sequel-cacheable/instance_methods.rb,
lib/sequel-cacheable/packer.rb,
lib/sequel-cacheable/driver.rb,
lib/sequel-cacheable.rb

Defined Under Namespace

Modules: ClassMethods, DatasetMethods, InstanceMethods Classes: DalliDriver, Driver, MemcacheDriver, MessagePackPacker, Packer, RedisDriver

Constant Summary collapse

VERSION =
'1.1.0'
DRIVERS =
%w(memcache dalli redis).freeze

Class Method Summary collapse

Class Method Details

.apply(model, store, options = {}) ⇒ Object



13
14
15
16
17
# File 'lib/sequel-cacheable.rb', line 13

def self.apply(model, store, options = {})
  model.instance_eval do
    plugin :after_initialize
  end
end

.configure(model, store, options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/sequel-cacheable.rb', line 19

def self.configure(model, store, options = {})
  model.instance_eval do
    @cache_options = {
      :ttl => 3600,
      :pack_lib => MessagePack,
      :query_cache => false
    }.merge(options)
    @cache_driver = Driver.factory(
      store,
      Packer.factory(@cache_options[:pack_lib])
    )
    @caches = {
      :instance => [],
      :query => []
    }
  end
end