arid_cache 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/arid_cache.gemspec +6 -4
- data/lib/arid_cache/cache_proxy.rb +8 -2
- data/spec/{arid_cache_spec.rb → arid_cache/arid_cache_spec.rb} +2 -2
- data/spec/arid_cache/cache_proxy_spec.rb +19 -0
- metadata +8 -6
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.4
|
data/arid_cache.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{arid_cache}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Karl Varga"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-29}
|
13
13
|
s.description = %q{AridCache makes caching easy and effective. AridCache supports caching on all your model named scopes, class methods and instance methods right out of the box. AridCache prevents caching logic from cluttering your models and clarifies your logic by making explicit calls to cached result sets.
|
14
14
|
AridCache is designed for handling large, expensive ActiveRecord collections but is equally useful for caching anything else as well.
|
15
15
|
}
|
@@ -34,7 +34,8 @@ AridCache is designed for handling large, expensive ActiveRecord collections but
|
|
34
34
|
"lib/arid_cache/helpers.rb",
|
35
35
|
"lib/arid_cache/store.rb",
|
36
36
|
"rails/init.rb",
|
37
|
-
"spec/arid_cache_spec.rb",
|
37
|
+
"spec/arid_cache/arid_cache_spec.rb",
|
38
|
+
"spec/arid_cache/cache_proxy_spec.rb",
|
38
39
|
"spec/spec.opts",
|
39
40
|
"spec/spec_helper.rb",
|
40
41
|
"spec/support/ar_query.rb",
|
@@ -60,7 +61,8 @@ AridCache is designed for handling large, expensive ActiveRecord collections but
|
|
60
61
|
s.rubygems_version = %q{1.3.7}
|
61
62
|
s.summary = %q{Automates efficient caching of your ActiveRecord collections, gives you counts for free and supports pagination.}
|
62
63
|
s.test_files = [
|
63
|
-
"spec/arid_cache_spec.rb",
|
64
|
+
"spec/arid_cache/arid_cache_spec.rb",
|
65
|
+
"spec/arid_cache/cache_proxy_spec.rb",
|
64
66
|
"spec/spec_helper.rb",
|
65
67
|
"spec/support/ar_query.rb",
|
66
68
|
"spec/support/custom_methods.rb",
|
@@ -312,13 +312,19 @@ module AridCache
|
|
312
312
|
#
|
313
313
|
# TODO: is it quicker to sort in memory?
|
314
314
|
def preserve_order(ids)
|
315
|
+
column = if self.klass.respond_to?(:table_name)
|
316
|
+
::ActiveRecord::Base.connection.quote_table_name(self.klass.table_name) + '.id'
|
317
|
+
else
|
318
|
+
"id"
|
319
|
+
end
|
320
|
+
|
315
321
|
if ids.empty?
|
316
322
|
nil
|
317
323
|
elsif ::ActiveRecord::Base.is_mysql_adapter?
|
318
|
-
"FIELD(
|
324
|
+
"FIELD(#{column},#{ids.join(',')})"
|
319
325
|
else
|
320
326
|
order = ''
|
321
|
-
ids.each_index { |i| order << "WHEN
|
327
|
+
ids.each_index { |i| order << "WHEN #{column}=#{ids[i]} THEN #{i+1} " }
|
322
328
|
"CASE " + order + " END"
|
323
329
|
end
|
324
330
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AridCache::CacheProxy do
|
4
|
+
describe 'id in order clause' do
|
5
|
+
before :each do
|
6
|
+
@proxy = AridCache::CacheProxy.new(Company, 'dummy-key', {})
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should be prefixed by the table name" do
|
10
|
+
::ActiveRecord::Base.stubs(:is_mysql_adapter?).returns(true)
|
11
|
+
@proxy.send(:preserve_order, [1,2,3]).should =~ %r[#{Company.table_name}]
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be prefixed by the table name" do
|
15
|
+
::ActiveRecord::Base.stubs(:is_mysql_adapter?).returns(false)
|
16
|
+
@proxy.send(:preserve_order, [1,2,3]).should =~ %r[#{Company.table_name}]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arid_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 4
|
10
|
+
version: 1.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Karl Varga
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-29 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -102,7 +102,8 @@ files:
|
|
102
102
|
- lib/arid_cache/helpers.rb
|
103
103
|
- lib/arid_cache/store.rb
|
104
104
|
- rails/init.rb
|
105
|
-
- spec/arid_cache_spec.rb
|
105
|
+
- spec/arid_cache/arid_cache_spec.rb
|
106
|
+
- spec/arid_cache/cache_proxy_spec.rb
|
106
107
|
- spec/spec.opts
|
107
108
|
- spec/spec_helper.rb
|
108
109
|
- spec/support/ar_query.rb
|
@@ -156,7 +157,8 @@ signing_key:
|
|
156
157
|
specification_version: 3
|
157
158
|
summary: Automates efficient caching of your ActiveRecord collections, gives you counts for free and supports pagination.
|
158
159
|
test_files:
|
159
|
-
- spec/arid_cache_spec.rb
|
160
|
+
- spec/arid_cache/arid_cache_spec.rb
|
161
|
+
- spec/arid_cache/cache_proxy_spec.rb
|
160
162
|
- spec/spec_helper.rb
|
161
163
|
- spec/support/ar_query.rb
|
162
164
|
- spec/support/custom_methods.rb
|