File tree 3 files changed +4
-1
lines changed
3 files changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module SecondLevelCache
3
3
module ActiveRecord
4
4
module FetchByUniqKey
5
5
def fetch_by_uniq_key ( value , uniq_key_name )
6
+ return self . where ( uniq_key_name => value ) . first unless self . second_level_cache_enabled?
6
7
if iid = SecondLevelCache . cache_store . read ( cache_uniq_key ( value , uniq_key_name ) )
7
8
self . find_by_id ( iid )
8
9
else
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ class << self
12
12
def dump ( record )
13
13
[
14
14
record . class . name ,
15
- record . instance_variable_get ( :@ attributes)
15
+ record . attributes
16
16
]
17
17
end
18
18
Original file line number Diff line number Diff line change 1
1
# -*- encoding : utf-8 -*-
2
2
ActiveRecord ::Base . connection . create_table ( :users , :force => true ) do |t |
3
+ t . text :options
3
4
t . string :name
4
5
t . string :email
5
6
t . integer :books_count , :default => 0
9
10
10
11
class User < ActiveRecord ::Base
11
12
CacheVersion = 3
13
+ serialize :options , Array
12
14
acts_as_cached ( :version => CacheVersion , :expires_in => 3 . day )
13
15
14
16
has_many :books
You can’t perform that action at this time.
0 commit comments