record-cache 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +8 -8
  2. data/lib/record_cache/base.rb +4 -4
  3. data/lib/record_cache/datastore/active_record_30.rb +1 -1
  4. data/lib/record_cache/datastore/active_record_31.rb +1 -1
  5. data/lib/record_cache/datastore/active_record_32.rb +2 -2
  6. data/lib/record_cache/datastore/active_record_40.rb +445 -0
  7. data/lib/record_cache/datastore/active_record_41.rb +446 -0
  8. data/lib/record_cache/strategy/full_table_cache.rb +1 -1
  9. data/lib/record_cache/strategy/util.rb +20 -3
  10. data/lib/record_cache/version.rb +1 -1
  11. data/spec/db/create-record-cache-db_and_user.sql +5 -0
  12. data/spec/db/database.yml +7 -0
  13. data/spec/db/schema.rb +9 -15
  14. data/spec/initializers/backward_compatibility.rb +32 -0
  15. data/spec/lib/active_record/visitor_spec.rb +1 -1
  16. data/spec/lib/base_spec.rb +2 -2
  17. data/spec/lib/dispatcher_spec.rb +1 -1
  18. data/spec/lib/multi_read_spec.rb +1 -1
  19. data/spec/lib/query_spec.rb +1 -1
  20. data/spec/lib/statistics_spec.rb +1 -1
  21. data/spec/lib/strategy/base_spec.rb +39 -39
  22. data/spec/lib/strategy/full_table_cache_spec.rb +18 -18
  23. data/spec/lib/strategy/index_cache_spec.rb +58 -52
  24. data/spec/lib/strategy/query_cache_spec.rb +1 -1
  25. data/spec/lib/strategy/unique_index_on_id_cache_spec.rb +57 -45
  26. data/spec/lib/strategy/unique_index_on_string_cache_spec.rb +47 -45
  27. data/spec/lib/strategy/util_spec.rb +49 -43
  28. data/spec/lib/version_store_spec.rb +1 -1
  29. data/spec/models/apple.rb +1 -2
  30. data/spec/spec_helper.rb +16 -7
  31. data/spec/support/matchers/hit_cache_matcher.rb +1 -1
  32. data/spec/support/matchers/miss_cache_matcher.rb +1 -1
  33. data/spec/support/matchers/use_cache_matcher.rb +1 -1
  34. metadata +63 -17
  35. data/spec/support/after_commit.rb +0 -73
@@ -19,7 +19,13 @@ module RecordCache
19
19
  record = serialized[CLASS_KEY].constantize.allocate
20
20
  attributes = serialized[ATTRIBUTES_KEY]
21
21
  record.class.serialized_attributes.keys.each do |attribute|
22
- attributes[attribute] = attributes[attribute].unserialize if attributes[attribute].respond_to?(:unserialize)
22
+ if attributes[attribute].respond_to?(:unserialize)
23
+ if attributes[attribute].method(:unserialize).arity > 0
24
+ attributes[attribute] = attributes[attribute].unserialize(attributes[attribute].value)
25
+ else
26
+ attributes[attribute] = attributes[attribute].unserialize
27
+ end
28
+ end
23
29
  end
24
30
  record.init_with('attributes' => attributes)
25
31
  record
@@ -27,15 +33,26 @@ module RecordCache
27
33
 
28
34
  # Filter the cached records in memory
29
35
  # only simple x = y or x IN (a,b,c) can be handled
36
+ # string comparison is case insensitive
30
37
  # Example:
31
38
  # RecordCache::Strategy::Util.filter!(Apple.all, :price => [0.49, 0.59, 0.69], :name => "Green Apple")
32
39
  def filter!(records, wheres)
33
40
  wheres.each_pair do |attr, value|
34
41
  attr = attr.to_sym
35
42
  if value.is_a?(Array)
36
- records.reject! { |record| !value.include?(record.send(attr)) }
43
+ where_values = Set.new(value.first.respond_to?(:downcase) ? value.map(&:downcase) : value)
44
+ records.to_a.select! do |record|
45
+ attribute_value = record.send(attr)
46
+ attribute_value = attribute_value.downcase if attribute_value.respond_to?(:downcase)
47
+ where_values.include?(attribute_value)
48
+ end
37
49
  else
38
- records.reject! { |record| record.send(attr) != value }
50
+ where_value = value.respond_to?(:downcase) ? value.downcase : value
51
+ records.to_a.select! do |record|
52
+ attribute_value = record.send(attr)
53
+ attribute_value = attribute_value.downcase if attribute_value.respond_to?(:downcase)
54
+ attribute_value == where_value
55
+ end
39
56
  end
40
57
  end
41
58
  end
@@ -1,5 +1,5 @@
1
1
  module RecordCache # :nodoc:
2
2
  module Version # :nodoc:
3
- STRING = '0.1.3'
3
+ STRING = '0.1.4'
4
4
  end
5
5
  end
@@ -0,0 +1,5 @@
1
+ DROP DATABASE IF EXISTS record_cache;
2
+ CREATE DATABASE record_cache;
3
+ CREATE USER 'record_cache'@'localhost' IDENTIFIED BY 'test';
4
+ GRANT ALL ON record_cache.* to 'record_cache'@'localhost';
5
+ FLUSH PRIVILEGES;
data/spec/db/database.yml CHANGED
@@ -4,3 +4,10 @@ sqlite3:
4
4
  encoding: utf8
5
5
  charset: utf8
6
6
  timeout: 5000
7
+
8
+
9
+ mysql:
10
+ adapter: mysql2
11
+ database: "record_cache"
12
+ username: record_cache
13
+ password: test
data/spec/db/schema.rb CHANGED
@@ -1,52 +1,46 @@
1
- ActiveRecord::Schema.define :version => 0 do
1
+ ActiveRecord::Schema.define version: 0 do
2
2
 
3
- create_table :people, :force => true do |t|
4
- t.integer :id
3
+ create_table :people, force: true do |t|
5
4
  t.string :name
6
5
  t.date :birthday
7
6
  t.float :height
8
7
  end
9
8
 
10
- create_table :stores, :force => true do |t|
11
- t.integer :id
9
+ create_table :stores, force: true do |t|
12
10
  t.string :name
13
11
  t.integer :owner_id
14
12
  end
15
13
 
16
- create_table :people_stores, :id => false, :force => true do |t|
14
+ create_table :people_stores, id: false, force: true do |t|
17
15
  t.integer :person_id
18
16
  t.string :store_id
19
17
  end
20
18
 
21
- create_table :apples, :force => true do |t|
22
- t.integer :id
19
+ create_table :apples, force: true do |t|
23
20
  t.string :name
24
21
  t.integer :store_id
25
22
  t.integer :person_id
26
23
  end
27
24
 
28
- create_table :bananas, :force => true do |t|
29
- t.integer :id
25
+ create_table :bananas, force: true do |t|
30
26
  t.string :name
31
27
  t.integer :store_id
32
28
  t.integer :person_id
33
29
  end
34
30
 
35
- create_table :pears, :force => true do |t|
36
- t.integer :id
31
+ create_table :pears, force: true do |t|
37
32
  t.string :name
38
33
  t.integer :store_id
39
34
  t.integer :person_id
40
35
  end
41
36
 
42
- create_table :addresses, :force => true do |t|
43
- t.integer :id
37
+ create_table :addresses, force: true do |t|
44
38
  t.string :name
45
39
  t.integer :store_id
46
40
  t.string :location
47
41
  end
48
42
 
49
- create_table :languages, :force => true do |t|
43
+ create_table :languages, force: true do |t|
50
44
  t.string :name
51
45
  t.string :locale
52
46
  end
@@ -0,0 +1,32 @@
1
+ if ActiveRecord::VERSION::MAJOR < 4
2
+
3
+ module ActiveRecord
4
+ class Base
5
+ class << self
6
+ # generic find_by introduced in Rails 4
7
+ def find_by(*args)
8
+ where(*args).first
9
+ rescue RangeError
10
+ nil
11
+ end unless method_defined? :find_by
12
+ end
13
+ end
14
+ end
15
+
16
+ module ActiveSupport
17
+ module Dependencies
18
+ module Loadable
19
+ # load without arguments in Rails 4 is similar to +to_a+ in Rails 3
20
+ def load_with_default(*args)
21
+ if self.respond_to?(:to_a)
22
+ self.to_a
23
+ else
24
+ self.load_without_default(*args)
25
+ end
26
+ end
27
+ alias_method_chain :load, :default
28
+ end
29
+ end
30
+ end
31
+
32
+ end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe 'ActiveRecord Visitor' do
4
+ RSpec.describe 'ActiveRecord Visitor' do
5
5
 
6
6
  def find_visit_methods(visitor_class)
7
7
  (visitor_class.instance_methods + visitor_class.private_instance_methods).select{ |method| method.to_s =~ /^visit_Arel_/ }.sort.uniq
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe RecordCache::Base do
4
+ RSpec.describe RecordCache::Base do
5
5
 
6
6
  it "should run a block in enabled mode" do
7
7
  RecordCache::Base.disable!
@@ -18,4 +18,4 @@ describe RecordCache::Base do
18
18
  RecordCache::Base.logger = nil
19
19
  expect(RecordCache::Base.logger).to eq(::ActiveRecord::Base.logger)
20
20
  end
21
- end
21
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RecordCache::Dispatcher do
3
+ RSpec.describe RecordCache::Dispatcher do
4
4
  before(:each) do
5
5
  @apple_dispatcher = Apple.record_cache
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RecordCache::MultiRead do
3
+ RSpec.describe RecordCache::MultiRead do
4
4
 
5
5
  it "should not delegate to single reads when multi_read is supported" do
6
6
  class MultiReadSupported
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RecordCache::Query do
3
+ RSpec.describe RecordCache::Query do
4
4
  before(:each) do
5
5
  @query = RecordCache::Query.new
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RecordCache::Statistics do
3
+ RSpec.describe RecordCache::Statistics do
4
4
  before(:each) do
5
5
  # remove active setting from other tests
6
6
  RecordCache::Statistics.send(:remove_instance_variable, :@active) if RecordCache::Statistics.instance_variable_get(:@active)
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'spec_helper'
3
3
 
4
- describe RecordCache::Strategy::Base do
4
+ RSpec.describe RecordCache::Strategy::Base do
5
5
 
6
6
  it "should force implementation of self.parse method" do
7
7
  module RecordCache
@@ -46,54 +46,54 @@ describe RecordCache::Strategy::Base do
46
46
 
47
47
  context "filter" do
48
48
  it "should apply filter on :id cache hits" do
49
- expect{ @apples = Apple.where(:id => [1,2]).where(:name => "Adams Apple 1").all }.to use_cache(Apple).on(:id)
50
- expect(@apples).to eq([Apple.find_by_name("Adams Apple 1")])
49
+ expect{ @apples = Apple.where(:id => [1,2]).where(:name => "Adams Apple 1").load }.to use_cache(Apple).on(:id)
50
+ expect(@apples).to eq([Apple.find_by(name: "Adams Apple 1")])
51
51
  end
52
-
52
+
53
53
  it "should apply filter on index cache hits" do
54
- expect{ @apples = Apple.where(:store_id => 1).where(:name => "Adams Apple 1").all }.to use_cache(Apple).on(:store_id)
55
- expect(@apples).to eq([Apple.find_by_name("Adams Apple 1")])
54
+ expect{ @apples = Apple.where(:store_id => 1).where(:name => "Adams Apple 1").load }.to use_cache(Apple).on(:store_id)
55
+ expect(@apples).to eq([Apple.find_by(name: "Adams Apple 1")])
56
56
  end
57
57
 
58
58
  it "should return empty array when filter does not match any record" do
59
- expect{ @apples = Apple.where(:store_id => 1).where(:name => "Adams Apple Pie").all }.to use_cache(Apple).on(:store_id)
59
+ expect{ @apples = Apple.where(:store_id => 1).where(:name => "Adams Apple Pie").load }.to use_cache(Apple).on(:store_id)
60
60
  expect(@apples).to be_empty
61
61
  end
62
62
 
63
63
  it "should filter on text" do
64
- expect{ @apples = Apple.where(:id => [1,2]).where(:name => "Adams Apple 1").all }.to use_cache(Apple).on(:id)
65
- expect(@apples).to eq([Apple.find_by_name("Adams Apple 1")])
64
+ expect{ @apples = Apple.where(:id => [1,2]).where(:name => "Adams Apple 1").load }.to use_cache(Apple).on(:id)
65
+ expect(@apples).to eq([Apple.find_by(name: "Adams Apple 1")])
66
66
  end
67
67
 
68
68
  it "should filter on integers" do
69
- expect{ @apples = Apple.where(:id => [1,2,8,9]).where(:store_id => 2).all }.to use_cache(Apple).on(:id)
69
+ expect{ @apples = Apple.where(:id => [1,2,8,9]).where(:store_id => 2).load }.to use_cache(Apple).on(:id)
70
70
  expect(@apples.map(&:id).sort).to eq([8,9])
71
71
  end
72
72
 
73
73
  it "should filter on dates" do
74
- expect{ @people = Person.where(:id => [1,2,3]).where(:birthday => Date.civil(1953,11,11)).all }.to use_cache(Person).on(:id)
74
+ expect{ @people = Person.where(:id => [1,2,3]).where(:birthday => Date.civil(1953,11,11)).load }.to use_cache(Person).on(:id)
75
75
  expect(@people.size).to eq(1)
76
76
  expect(@people.first.name).to eq("Blue")
77
77
  end
78
78
 
79
79
  it "should filter on floats" do
80
- expect{ @people = Person.where(:id => [1,2,3]).where(:height => 1.75).all }.to use_cache(Person).on(:id)
80
+ expect{ @people = Person.where(:id => [1,2,3]).where(:height => 1.75).load }.to use_cache(Person).on(:id)
81
81
  expect(@people.size).to eq(2)
82
82
  expect(@people.map(&:name).sort).to eq(["Blue", "Cris"])
83
83
  end
84
84
 
85
85
  it "should filter on arrays" do
86
- expect{ @apples = Apple.where(:id => [1,2,8,9]).where(:store_id => [2, 4]).all }.to use_cache(Apple).on(:id)
86
+ expect{ @apples = Apple.where(:id => [1,2,8,9]).where(:store_id => [2, 4]).load }.to use_cache(Apple).on(:id)
87
87
  expect(@apples.map(&:id).sort).to eq([8,9])
88
88
  end
89
-
89
+
90
90
  it "should filter on multiple fields" do
91
91
  # make sure two apples exist with the same name
92
92
  @apple = Apple.find(8)
93
93
  @apple.name = Apple.find(9).name
94
94
  @apple.save!
95
95
 
96
- expect{ @apples = Apple.where(:id => [1,2,3,8,9,10]).where(:store_id => 2).where(:name => @apple.name).all }.to use_cache(Apple).on(:id)
96
+ expect{ @apples = Apple.where(:id => [1,2,3,8,9,10]).where(:store_id => 2).where(:name => @apple.name).load }.to use_cache(Apple).on(:id)
97
97
  expect(@apples.size).to eq(2)
98
98
  expect(@apples.map(&:name)).to eq([@apple.name, @apple.name])
99
99
  expect(@apples.map(&:id).sort).to eq([8,9])
@@ -103,94 +103,94 @@ describe RecordCache::Strategy::Base do
103
103
 
104
104
  context "sort" do
105
105
  it "should apply sort on :id cache hits" do
106
- expect{ @people = Person.where(:id => [1,2,3]).order("name DESC").all }.to use_cache(Person).on(:id)
106
+ expect{ @people = Person.where(:id => [1,2,3]).order("name DESC").load }.to use_cache(Person).on(:id)
107
107
  expect(@people.map(&:name)).to eq(["Cris", "Blue", "Adam"])
108
108
  end
109
109
 
110
110
  it "should apply sort on index cache hits" do
111
- expect{ @apples = Apple.where(:store_id => 1).order("person_id ASC").all }.to use_cache(Apple).on(:store_id)
111
+ expect{ @apples = Apple.where(:store_id => 1).order("person_id ASC").load }.to use_cache(Apple).on(:store_id)
112
112
  expect(@apples.map(&:person_id)).to eq([nil, nil, 4, 4, 5])
113
113
  end
114
-
114
+
115
115
  it "should default to ASC" do
116
- expect{ @apples = Apple.where(:store_id => 1).order("person_id").all }.to use_cache(Apple).on(:store_id)
116
+ expect{ @apples = Apple.where(:store_id => 1).order("person_id").load }.to use_cache(Apple).on(:store_id)
117
117
  expect(@apples.map(&:person_id)).to eq([nil, nil, 4, 4, 5])
118
118
  end
119
119
 
120
120
  it "should apply sort nil first for ASC" do
121
- expect{ @apples = Apple.where(:store_id => 1).order("person_id ASC").all }.to use_cache(Apple).on(:store_id)
121
+ expect{ @apples = Apple.where(:store_id => 1).order("person_id ASC").load }.to use_cache(Apple).on(:store_id)
122
122
  expect(@apples.map(&:person_id)).to eq([nil, nil, 4, 4, 5])
123
123
  end
124
124
 
125
125
  it "should apply sort nil last for DESC" do
126
- expect{ @apples = Apple.where(:store_id => 1).order("person_id DESC").all }.to use_cache(Apple).on(:store_id)
126
+ expect{ @apples = Apple.where(:store_id => 1).order("person_id DESC").load }.to use_cache(Apple).on(:store_id)
127
127
  expect(@apples.map(&:person_id)).to eq([5, 4, 4, nil, nil])
128
128
  end
129
129
 
130
130
  it "should sort ascending on text" do
131
- expect{ @people = Person.where(:id => [1,2,3,4]).order("name ASC").all }.to use_cache(Person).on(:id)
131
+ expect{ @people = Person.where(:id => [1,2,3,4]).order("name ASC").load }.to use_cache(Person).on(:id)
132
132
  expect(@people.map(&:name)).to eq(["Adam", "Blue", "Cris", "Fry"])
133
133
  end
134
134
 
135
135
  it "should sort descending on text" do
136
- expect{ @people = Person.where(:id => [1,2,3,4]).order("name DESC").all }.to use_cache(Person).on(:id)
136
+ expect{ @people = Person.where(:id => [1,2,3,4]).order("name DESC").load }.to use_cache(Person).on(:id)
137
137
  expect(@people.map(&:name)).to eq(["Fry", "Cris", "Blue", "Adam"])
138
138
  end
139
139
 
140
140
  it "should sort ascending on integers" do
141
- expect{ @people = Person.where(:id => [1,2,3,4]).order("id ASC").all }.to use_cache(Person).on(:id)
141
+ expect{ @people = Person.where(:id => [1,2,3,4]).order("id ASC").load }.to use_cache(Person).on(:id)
142
142
  expect(@people.map(&:id)).to eq([1,2,3,4])
143
143
  end
144
144
 
145
145
  it "should sort descending on integers" do
146
- expect{ @people = Person.where(:id => [1,2,3,4]).order("id DESC").all }.to use_cache(Person).on(:id)
146
+ expect{ @people = Person.where(:id => [1,2,3,4]).order("id DESC").load }.to use_cache(Person).on(:id)
147
147
  expect(@people.map(&:id)).to eq([4,3,2,1])
148
148
  end
149
149
 
150
150
  it "should sort ascending on dates" do
151
- expect{ @people = Person.where(:id => [1,2,3,4]).order("birthday ASC").all }.to use_cache(Person).on(:id)
151
+ expect{ @people = Person.where(:id => [1,2,3,4]).order("birthday ASC").load }.to use_cache(Person).on(:id)
152
152
  expect(@people.map(&:birthday)).to eq([Date.civil(1953,11,11), Date.civil(1975,03,20), Date.civil(1975,03,20), Date.civil(1985,01,20)])
153
153
  end
154
154
 
155
155
  it "should sort descending on dates" do
156
- expect{ @people = Person.where(:id => [1,2,3,4]).order("birthday DESC").all }.to use_cache(Person).on(:id)
156
+ expect{ @people = Person.where(:id => [1,2,3,4]).order("birthday DESC").load }.to use_cache(Person).on(:id)
157
157
  expect(@people.map(&:birthday)).to eq([Date.civil(1985,01,20), Date.civil(1975,03,20), Date.civil(1975,03,20), Date.civil(1953,11,11)])
158
158
  end
159
159
 
160
160
  it "should sort ascending on float" do
161
- expect{ @people = Person.where(:id => [1,2,3,4]).order("height ASC").all }.to use_cache(Person).on(:id)
161
+ expect{ @people = Person.where(:id => [1,2,3,4]).order("height ASC").load }.to use_cache(Person).on(:id)
162
162
  expect(@people.map(&:height)).to eq([1.69, 1.75, 1.75, 1.83])
163
163
  end
164
164
 
165
165
  it "should sort descending on float" do
166
- expect{ @people = Person.where(:id => [1,2,3,4]).order("height DESC").all }.to use_cache(Person).on(:id)
166
+ expect{ @people = Person.where(:id => [1,2,3,4]).order("height DESC").load }.to use_cache(Person).on(:id)
167
167
  expect(@people.map(&:height)).to eq([1.83, 1.75, 1.75, 1.69])
168
168
  end
169
169
 
170
170
  it "should sort on multiple fields (ASC + ASC)" do
171
- expect{ @people = Person.where(:id => [2,3,4,5]).order("height ASC, id ASC").all }.to use_cache(Person).on(:id)
171
+ expect{ @people = Person.where(:id => [2,3,4,5]).order("height ASC, id ASC").load }.to use_cache(Person).on(:id)
172
172
  expect(@people.map(&:height)).to eq([1.69, 1.75, 1.75, 1.91])
173
173
  expect(@people.map(&:id)).to eq([4, 2, 3, 5])
174
174
  end
175
175
 
176
176
  it "should sort on multiple fields (ASC + DESC)" do
177
- expect{ @people = Person.where(:id => [2,3,4,5]).order("height ASC, id DESC").all }.to use_cache(Person).on(:id)
177
+ expect{ @people = Person.where(:id => [2,3,4,5]).order("height ASC, id DESC").load }.to use_cache(Person).on(:id)
178
178
  expect(@people.map(&:height)).to eq([1.69, 1.75, 1.75, 1.91])
179
179
  expect(@people.map(&:id)).to eq([4, 3, 2, 5])
180
180
  end
181
181
 
182
182
  it "should sort on multiple fields (DESC + ASC)" do
183
- expect{ @people = Person.where(:id => [2,3,4,5]).order("height DESC, id ASC").all }.to use_cache(Person).on(:id)
183
+ expect{ @people = Person.where(:id => [2,3,4,5]).order("height DESC, id ASC").load }.to use_cache(Person).on(:id)
184
184
  expect(@people.map(&:height)).to eq([1.91, 1.75, 1.75, 1.69])
185
185
  expect(@people.map(&:id)).to eq([5, 2, 3, 4])
186
186
  end
187
187
 
188
188
  it "should sort on multiple fields (DESC + DESC)" do
189
- expect{ @people = Person.where(:id => [2,3,4,5]).order("height DESC, id DESC").all }.to use_cache(Person).on(:id)
189
+ expect{ @people = Person.where(:id => [2,3,4,5]).order("height DESC, id DESC").load }.to use_cache(Person).on(:id)
190
190
  expect(@people.map(&:height)).to eq([1.91, 1.75, 1.75, 1.69])
191
191
  expect(@people.map(&:id)).to eq([5, 3, 2, 4])
192
192
  end
193
-
193
+
194
194
  it "should use mysql style collation" do
195
195
  ids = []
196
196
  ids << Person.create!(:name => "ċedriĉ 3").id # latin other special
@@ -207,23 +207,23 @@ describe RecordCache::Strategy::Base do
207
207
  ids << Person.create!(:name => "čedriĉ ꜩ Last").id # latin special, with latin non-collateable
208
208
 
209
209
  names_asc = ["1 cedric", "a cedric", "cedric 1", "Cedric 2", "ċedriĉ 3", "čedriĉ 4", "ćedriĉ Last", "čedriĉ คฉ Almost last cedric", "čedriĉ ꜩ Last", "sedric 1", "Sedric 2", "คฉ Really last"]
210
- expect{ @people = Person.where(:id => ids).order("name ASC").all }.to hit_cache(Person).on(:id).times(ids.size)
210
+ expect{ @people = Person.where(:id => ids).order("name ASC").load }.to hit_cache(Person).on(:id).times(ids.size)
211
211
  expect(@people.map(&:name)).to eq(names_asc)
212
212
 
213
- expect{ @people = Person.where(:id => ids).order("name DESC").all }.to hit_cache(Person).on(:id).times(ids.size)
213
+ expect{ @people = Person.where(:id => ids).order("name DESC").load }.to hit_cache(Person).on(:id).times(ids.size)
214
214
  expect(@people.map(&:name)).to eq(names_asc.reverse)
215
215
  end
216
216
  end
217
217
 
218
218
  it "should combine filter and sort" do
219
- expect{ @people = Person.where(:id => [1,2,3]).where(:height => 1.75).order("name DESC").all }.to use_cache(Person).on(:id)
219
+ expect{ @people = Person.where(:id => [1,2,3]).where(:height => 1.75).order("name DESC").load }.to use_cache(Person).on(:id)
220
220
  expect(@people.size).to eq(2)
221
221
  expect(@people.map(&:name)).to eq(["Cris", "Blue"])
222
222
 
223
- expect{ @people = Person.where(:id => [1,2,3]).where(:height => 1.75).order("name").all }.to hit_cache(Person).on(:id).times(3)
223
+ expect{ @people = Person.where(:id => [1,2,3]).where(:height => 1.75).order("name").load }.to hit_cache(Person).on(:id).times(3)
224
224
  expect(@people.map(&:name)).to eq(["Blue", "Cris"])
225
225
  end
226
-
226
+
227
227
  context "NotImplementedError" do
228
228
  before(:each) do
229
229
  @invalid_strategy = RecordCache::Strategy::Base.new(Object, nil, nil, {:key => "key"})