Module: Cash

Included in:
ActiveRecord::Base
Defined in:
lib/cash/adapter/redis.rb,
lib/cash/fake.rb,
lib/cash/lock.rb,
lib/cash/mock.rb,
lib/cash/index.rb,
lib/cash/local.rb,
lib/cache_money.rb,
lib/cash/config.rb,
lib/cash/finders.rb,
lib/cash/request.rb,
lib/cash/version.rb,
lib/cash/accessor.rb,
lib/cash/buffered.rb,
lib/cash/query/select.rb,
lib/cash/transactional.rb,
lib/cash/write_through.rb,
lib/cash/query/abstract.rb,
lib/cash/adapter/memcached.rb,
lib/cash/query/calculation.rb,
lib/cash/query/primary_key.rb,
lib/cash/adapter/memcache_client.rb

Overview

Maps memcached methods and semantics to those of memcache-client

Defined Under Namespace

Modules: Accessor, Adapter, ClassMethods, Config, Finders, Query, WriteThrough Classes: Buffered, Command, Fake, Index, Local, LocalBuffer, Lock, Mock, NestedBuffered, Transactional

Constant Summary collapse

Request =
{}
VERSION =
'0.2.24.2'

Class Method Summary collapse

Class Method Details

.configure(options = {}) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cache_money.rb', line 32

def self.configure(options = {})
  options.assert_valid_keys(:repository, :local, :transactional, :adapter, :default_ttl)
  cache = options[:repository] || raise(":repository is a required option")
  
  adapter = options.fetch(:adapter, :memcached)
  
  if adapter
    require "cash/adapter/#{adapter.to_s}"
    klass = "Cash::Adapter::#{adapter.to_s.camelize}".constantize
    cache = klass.new(cache, :logger => Rails.logger, :default_ttl => options.fetch(:default_ttl, 1.day.to_i))
  end
  
  lock  = Cash::Lock.new(cache)
  cache = Cash::Local.new(cache) if options.fetch(:local, true)
  cache = Cash::Transactional.new(cache, lock) if options.fetch(:transactional, true)
  
  self.repository = cache
end

.included(active_record_class) ⇒ Object



51
52
53
54
55
56
# File 'lib/cache_money.rb', line 51

def self.included(active_record_class)
  active_record_class.class_eval do
    include Config, Accessor, WriteThrough, Finders
    extend ClassMethods
  end
end