Module: Itrigga::Cache

Defined in:
lib/itrigga/cache/cache.rb,
lib/itrigga/cache/dalli.rb,
lib/itrigga/cache/memcache.rb,
lib/itrigga/cache/filecache.rb

Defined Under Namespace

Modules: ClassMethods, ControllerMethods, InstanceMethods Classes: Dalli, Filecache, Memcache

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



9
10
11
12
13
14
# File 'lib/itrigga/cache/cache.rb', line 9

def self.included(base)
  base.extend(ClassMethods)
  base.send(:include, InstanceMethods)
  base.send(:include, Trigga::ParamFu)
  base.send(:include, ControllerMethods) if defined?(ActionController::Base) && base.ancestors.include?(ActionController::Base)
end

.instance(opts = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/itrigga/cache/cache.rb', line 28

def self.instance(opts = {})
  case ( opts[:backend] ||= @default_cache_type )
    when :memcached          
      Itrigga::Cache::Memcache.instance
    when :dalli          
      Itrigga::Cache::Dalli.instance
    when :filecache
      Itrigga::Cache::Filecache.instance
    else
      nil
  end
end

.setup!(opts = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/itrigga/cache/cache.rb', line 16

def self.setup!(opts ={})
  @default_cache_type = opts[:backend] if opts[:backend]
  case opts[:backend]
  when :memcached
    Itrigga::Cache::Memcache.setup!(opts)       
  when :dalli
    Itrigga::Cache::Dalli.setup!(opts)
  else
    Itrigga::Cache::Filecache.setup!(opts)
  end
end