kmayer-highrise 0.9.0 → 0.9.1
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/VERSION.yml +1 -1
- data/lib/cachable.rb +8 -8
- data/spec/highrise/cachable_spec.rb +5 -5
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/cachable.rb
CHANGED
@@ -23,9 +23,9 @@ require 'digest/sha1'
|
|
23
23
|
# Configuration examples ('off' is the default):
|
24
24
|
#
|
25
25
|
# CachedResource.connection.cache_store = :memory_store
|
26
|
-
# CachedResource.connection.cache_store = :file_store, "/path/to/cache/directory"
|
27
|
-
# CachedResource.connection.cache_store = :drb_store, "druby://localhost:9192"
|
28
|
-
# CachedResource.connection.cache_store = :mem_cache_store, "localhost"
|
26
|
+
# CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :file_store, "/path/to/cache/directory"
|
27
|
+
# CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :drb_store, "druby://localhost:9192"
|
28
|
+
# CachedResource.connection.cache_store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost"
|
29
29
|
# CachedResource.connection.cache_store = MyOwnStore.new("parameter")
|
30
30
|
#
|
31
31
|
# Note: To ensure that caching is turned off, set CachedResource.connection.cache_store = :none
|
@@ -44,15 +44,15 @@ module Cachable
|
|
44
44
|
# Wrapper for lookup_store, with a couple of special options:
|
45
45
|
# Passing +:none+ will turn off caching
|
46
46
|
# Passing +:rails+ will use the default Rails/AS cache (whatever it happens to be)
|
47
|
-
# Passing
|
48
|
-
def cache_store=(
|
47
|
+
# Passing +nil+ will use the default cache from AS
|
48
|
+
def cache_store=(store_option)
|
49
49
|
@cache_store = case store_option
|
50
|
-
when
|
50
|
+
when :none
|
51
51
|
nil
|
52
|
-
when
|
52
|
+
when :rails
|
53
53
|
Rails.cache rescue ActiveSupport::Cache.lookup_store
|
54
54
|
else
|
55
|
-
ActiveSupport::Cache.lookup_store(
|
55
|
+
ActiveSupport::Cache.lookup_store(store_option)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -30,13 +30,13 @@ describe Highrise::Base do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
after(:all) do
|
33
|
-
@connection.cache_store =
|
33
|
+
@connection.cache_store = :none
|
34
34
|
end
|
35
35
|
|
36
36
|
before(:each) do
|
37
37
|
@thing = Highrise::Base.new
|
38
38
|
@key = :key
|
39
|
-
@connection.
|
39
|
+
@connection.stub!(:cache_key).and_return(@key)
|
40
40
|
end
|
41
41
|
|
42
42
|
context "when a cached response is available" do
|
@@ -50,7 +50,7 @@ describe Highrise::Base do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should read from the cache" do
|
53
|
-
Highrise::Base.find(
|
53
|
+
Highrise::Base.find(1).should == @thing
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -61,12 +61,12 @@ describe Highrise::Base do
|
|
61
61
|
|
62
62
|
it "SHOULD perform an ARes request" do
|
63
63
|
@connection.should_receive(:get_without_cache).and_return(@thing.attributes)
|
64
|
-
Highrise::Base.find(
|
64
|
+
Highrise::Base.find(1)
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should cache the response using the caching key" do
|
68
68
|
@connection.should_receive(:get_without_cache).and_return(@thing.attributes)
|
69
|
-
Highrise::Base.find(
|
69
|
+
Highrise::Base.find(1)
|
70
70
|
@connection.cache_store.read(@key).should == @thing.attributes
|
71
71
|
end
|
72
72
|
end
|