Skip to content
This repository
Newer
Older
100644 55 lines (45 sloc) 1.214 kb
700c80e7 »
2008-12-11 fixes
1 $LOAD_PATH.unshift(File.dirname(__FILE__))
2
3 require 'rubygems'
4 require 'activesupport'
5 require 'activerecord'
6
7 require 'cash/lock'
8 require 'cash/transactional'
9 require 'cash/write_through'
10 require 'cash/finders'
11 require 'cash/buffered'
12 require 'cash/index'
13 require 'cash/config'
14 require 'cash/accessor'
15
16 require 'cash/request'
17 require 'cash/mock'
18 require 'cash/local'
19
20 require 'cash/query/abstract'
21 require 'cash/query/select'
22 require 'cash/query/primary_key'
23 require 'cash/query/calculation'
24
25 require 'cash/util/array'
26
27 class ActiveRecord::Base
28 def self.is_cached(options = {})
c29b0f8a »
2008-12-11 paranoia
29 options.assert_valid_keys(:ttl, :repository, :version)
700c80e7 »
2008-12-11 fixes
30 include Cash
31 Config.create(self, options)
32 end
33 end
34
35 module Cash
36 def self.included(active_record_class)
37 active_record_class.class_eval do
38 include Config, Accessor, WriteThrough, Finders
39 extend ClassMethods
40 end
41 end
42
43 module ClassMethods
44 def self.extended(active_record_class)
45 class << active_record_class
46 alias_method_chain :transaction, :cache_transaction
47 end
48 end
49
50 def transaction_with_cache_transaction(&block)
51 repository.transaction { transaction_without_cache_transaction(&block) }
52 end
53 end
54 end
Something went wrong with that request. Please try again.