ngmoco-cache-money 0.2.22 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cash/query/abstract.rb +3 -1
- data/spec/cash/finders_spec.rb +22 -0
- metadata +5 -5
data/lib/cash/query/abstract.rb
CHANGED
@@ -190,7 +190,9 @@ module Cash
|
|
190
190
|
options = {}
|
191
191
|
order_sql = @options1[:order] || @options2[:order]
|
192
192
|
options[:order] = order_sql if order_sql
|
193
|
-
find_from_ids_without_cache(missing_ids, options)
|
193
|
+
results = find_from_ids_without_cache(missing_ids, options)
|
194
|
+
results.each {|o| @active_record.add_to_caches(o) } if results && results.is_a?(Array)
|
195
|
+
results
|
194
196
|
end
|
195
197
|
end
|
196
198
|
end
|
data/spec/cash/finders_spec.rb
CHANGED
@@ -386,6 +386,12 @@ module Cash
|
|
386
386
|
Short.find(:all, :conditions => { :subtitle => @short1.subtitle },
|
387
387
|
:order => 'title').map(&:id).should == [@short2.id, @short1.id]
|
388
388
|
end
|
389
|
+
|
390
|
+
# it 'pulls multiple objects from the cache, not the database' do
|
391
|
+
# mock(Story.connection).execute.never
|
392
|
+
# Short.find(:all, :conditions => { :subtitle => @short1.subtitle },
|
393
|
+
# :order => 'title').should_not be_empty
|
394
|
+
# end
|
389
395
|
end
|
390
396
|
|
391
397
|
describe '#find(1)' do
|
@@ -395,6 +401,22 @@ module Cash
|
|
395
401
|
end
|
396
402
|
end
|
397
403
|
|
404
|
+
describe '#find([1, 2, ...])' do
|
405
|
+
before do
|
406
|
+
@short1 = Short.create(:title => 'title1', :subtitle => 'subtitle')
|
407
|
+
@short2 = Short.create(:title => 'title2', :subtitle => 'subtitle')
|
408
|
+
@short3 = Short.create(:title => 'title3', :subtitle => 'subtitle')
|
409
|
+
$memcache.flush_all
|
410
|
+
end
|
411
|
+
|
412
|
+
it 'populates the cache' do
|
413
|
+
Short.find(@short1.id, @short2.id, @short3.id) == [@short1, @short2, @short3]
|
414
|
+
Short.fetch("id/#{@short1.id}").should == [@short1]
|
415
|
+
Short.fetch("id/#{@short2.id}").should == [@short2]
|
416
|
+
Short.fetch("id/#{@short3.id}").should == [@short3]
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
398
420
|
describe 'when there is a with_scope' do
|
399
421
|
it "uses the database, not the cache" do
|
400
422
|
Story.send :with_scope, :find => { :conditions => { :title => @story.title }} do
|
metadata
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ngmoco-cache-money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 23
|
10
|
+
version: 0.2.23
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nick Kallen
|
14
14
|
- Ashley Martens
|
15
15
|
- Scott Mace
|
16
|
-
- John
|
16
|
+
- John O'Neill
|
17
17
|
autorequire:
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2010-
|
21
|
+
date: 2010-11-23 00:00:00 -08:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|