bchiu-merb_cache_more 0.9.4
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/LICENSE +20 -0
- data/README +204 -0
- data/Rakefile +81 -0
- data/TODO +1 -0
- data/lib/merb_cache_more.rb +33 -0
- data/lib/merb_cache_more/cache-action.rb +176 -0
- data/lib/merb_cache_more/cache-fragment.rb +95 -0
- data/lib/merb_cache_more/cache-page.rb +248 -0
- data/lib/merb_cache_more/cache-store/database-activerecord.rb +88 -0
- data/lib/merb_cache_more/cache-store/database-datamapper.rb +79 -0
- data/lib/merb_cache_more/cache-store/database-sequel.rb +78 -0
- data/lib/merb_cache_more/cache-store/database.rb +144 -0
- data/lib/merb_cache_more/cache-store/dummy.rb +106 -0
- data/lib/merb_cache_more/cache-store/file.rb +194 -0
- data/lib/merb_cache_more/cache-store/memcache.rb +195 -0
- data/lib/merb_cache_more/cache-store/memory.rb +168 -0
- data/lib/merb_cache_more/merb-cache.rb +239 -0
- data/lib/merb_cache_more/merbtasks.rb +6 -0
- data/lib/merb_cache_more/request.rb +59 -0
- data/lib/merb_cache_more/request_helper.rb +40 -0
- data/spec/cache_action_params_spec.rb +76 -0
- data/spec/cache_action_spec.rb +137 -0
- data/spec/cache_controller.rb +85 -0
- data/spec/cache_fragment_spec.rb +100 -0
- data/spec/cache_keys_spec.rb +45 -0
- data/spec/cache_page_params_spec.rb +79 -0
- data/spec/cache_page_spec.rb +150 -0
- data/spec/config/database.yml +14 -0
- data/spec/merb_cache_more_spec.rb +18 -0
- data/spec/spec_helper.rb +82 -0
- data/spec/views/cache_controller/action1.html.erb +4 -0
- data/spec/views/cache_controller/action2.html.haml +4 -0
- metadata +99 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
describe "cache key generator" do
|
2
|
+
|
3
|
+
u1 = "/items/list"
|
4
|
+
q1 = "key1=val1&key2[a]=val2a&key3[]=val3a&key3[]=val3b"
|
5
|
+
p1 = Merb::Request.query_parse(q1, '&', true)
|
6
|
+
|
7
|
+
u2 = "http://www.google.com"
|
8
|
+
q2 = "q=cache:MrZoPWIJNhIJ:www.merbivore.com/+merb&hl=en&ct=clnk&cd=1"
|
9
|
+
p2 = Merb::Request.query_parse(q2, '&', true)
|
10
|
+
|
11
|
+
it "should return a default key" do
|
12
|
+
CACHE._cache.key_for({:key => u1, :format => nil, :params => nil}).should == "/items/list"
|
13
|
+
CACHE._cache.key_for({:key => u2, :format => nil, :params => nil}).should == "http://www.google.com"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return a default key using params" do
|
17
|
+
CACHE._cache.key_for({:key => u1, :format => nil, :params => p1}).should == "/items/list/key1_val1_key2_aval2a_key3_val3a_val3b"
|
18
|
+
CACHE._cache.key_for({:key => u2, :format => nil, :params => p2}).should == "http://www.google.com/q_cache_MrZoPWIJNhIJ_www.merbivore.com%2F_merb_hl_en_ct_clnk_cd_1"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return a snake key using params" do
|
22
|
+
CACHE._cache.key_for({:key => u1, :format => :snake, :params => p1}).should == "/items/list/val1_val2a_val3a_val3b"
|
23
|
+
CACHE._cache.key_for({:key => u2, :format => :snake, :params => p2}).should == "http://www.google.com/cache_MrZoPWIJNhIJ_www.merbivore.com%2F_merb_en_clnk_1"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return a hash key using params" do
|
27
|
+
CACHE._cache.key_for({:key => u1, :format => :hash, :params => p1}).should match(/^\/items\/list\/[a-z0-9]{32}$/i)
|
28
|
+
CACHE._cache.key_for({:key => u2, :format => :hash, :params => p2}).should match(/^http\:\/\/www.google.com\/[a-z0-9]{32}$/i)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return a tree key using params" do
|
32
|
+
CACHE._cache.key_for({:key => u1, :format => :tree, :params => p1}).should == "/items/list/val1/val2a/val3a/val3b"
|
33
|
+
CACHE._cache.key_for({:key => u2, :format => :tree, :params => p2}).should == "http://www.google.com/cache_MrZoPWIJNhIJ_www.merbivore.com%2F_merb/en/clnk/1"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return a query key using params" do
|
37
|
+
CACHE._cache.key_for({:key => u1, :format => :query, :params => p1}).should == "/items/list/key1=val1&key2[a]=val2a&key3[]=val3a&key3[]=val3b"
|
38
|
+
CACHE._cache.key_for({:key => u2, :format => :query, :params => p2}).should == "http://www.google.com/q=cache%3AMrZoPWIJNhIJ%3Awww.merbivore.com%2F+merb&hl=en&ct=clnk&cd=1"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return a custom key using params" do
|
42
|
+
CACHE._cache.key_for({:key => u1, :format => ":key1/:key2[a]_and_:key3[]", :params => p1}).should == "/items/list/val1/val2a_and_val3a"
|
43
|
+
CACHE._cache.key_for({:key => u2, :format => ":q/:hl_:ct_and_:cd", :params => p2}).should == "http://www.google.com/cache_MrZoPWIJNhIJ_www.merbivore.com%2F_merb/en_clnk_and_1"
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
describe "cache_page with params" do
|
2
|
+
|
3
|
+
qs = "p1=abc&p2=456&p3=ghi"
|
4
|
+
|
5
|
+
it "should cache page (action5) with params in default format" do
|
6
|
+
c = get("/cache_controller/action5", {}, {:query_string => qs})
|
7
|
+
c.body.strip.should == "test action5"
|
8
|
+
c.cached_page?(:key => "/cache_controller/action5/p1_abc_p2_456_p3_ghi").should be_true
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should expire page (action5) with params in default format" do
|
12
|
+
c = get("/cache_controller/action5", {}, {:query_string => qs})
|
13
|
+
c.expire_page(:key => "/cache_controller/action5/p1_abc_p2_456_p3_ghi")
|
14
|
+
c.cached_page?(:key => "/cache_controller/action5/p1_abc_p2_456_p3_ghi").should be_false
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should cache page (action5) with full path and params in default format" do
|
18
|
+
c = get("/cache_controller/action5/foo/bar", {}, {:query_string => qs})
|
19
|
+
c.body.strip.should == "test action5"
|
20
|
+
c.cached_page?(:key => "/cache_controller/action5/foo/bar/p1_abc_p2_456_p3_ghi").should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should expire page (action5) with full path and params in default format" do
|
24
|
+
c = get("/cache_controller/action5/foo/bar", {}, {:query_string => qs})
|
25
|
+
c.expire_page(:key => "/cache_controller/action5/foo/bar/p1_abc_p2_456_p3_ghi")
|
26
|
+
c.cached_page?(:key => "/cache_controller/action5/foo/bar/p1_abc_p2_456_p3_ghi").should be_false
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should cache page (action18) with specific params" do
|
30
|
+
c = get("/cache_controller/action18", {}, {:query_string => qs})
|
31
|
+
c.cached_page?(:key => "/cache_controller/action18/p1_abc_p2_456").should be_true
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should expire page (action18) with specific params" do
|
35
|
+
c = get("/cache_controller/action18", {}, {:query_string => qs})
|
36
|
+
c.expire_page(:key => "/cache_controller/action18/p1_abc_p2_456")
|
37
|
+
c.cached_page?(:key => "/cache_controller/action18/p1_abc_p2_456").should be_false
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should cache pages with params in every key format" do
|
41
|
+
c = get("/cache_controller/action19", {}, {:query_string => qs}) # snake
|
42
|
+
c.cached_page?(:key => "/cache_controller/action19/abc_456_ghi").should be_true
|
43
|
+
|
44
|
+
c = get("/cache_controller/action20", {}, {:query_string => qs}) # tree
|
45
|
+
c.cached_page?(:key => "/cache_controller/action20/abc/456/ghi").should be_true
|
46
|
+
|
47
|
+
c = get("/cache_controller/action21", {}, {:query_string => qs}) # hash
|
48
|
+
c.cached_page?(:key => "/cache_controller/action21/" + Digest::MD5.hexdigest("p1abcp2456p3ghi")).should be_true
|
49
|
+
|
50
|
+
c = get("/cache_controller/action22", {}, {:query_string => qs}) # query
|
51
|
+
c.cached_page?(:key => "/cache_controller/action22/p1=abc&p2=456&p3=ghi").should be_true
|
52
|
+
|
53
|
+
c = get("/cache_controller/action23", {}, {:query_string => qs}) # custom
|
54
|
+
c.cached_page?(:key => "/cache_controller/action23/abc/456_and_ghi").should be_true
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should expire pages with params in every key format" do
|
58
|
+
CACHE.expire_page(:key => "/cache_controller/action19/abc_456_ghi")
|
59
|
+
CACHE.cached_page?(:key => "/cache_controller/action19/abc_456_ghi").should be_false
|
60
|
+
|
61
|
+
CACHE.expire_page(:key => "/cache_controller/action20/abc/456/ghi")
|
62
|
+
CACHE.cached_page?(:key => "/cache_controller/action20/abc/456/ghi").should be_false
|
63
|
+
|
64
|
+
CACHE.expire_page(:key => "/cache_controller/action21/" + Digest::MD5.hexdigest("p1abcp2456p3ghi"))
|
65
|
+
CACHE.cached_page?(:key => "/cache_controller/action21/" + Digest::MD5.hexdigest("p1abcp2456p3ghi")).should be_false
|
66
|
+
|
67
|
+
CACHE.expire_page(:key => "/cache_controller/action22/p1=abc&p2=456&p3=ghi")
|
68
|
+
CACHE.cached_page?(:key => "/cache_controller/action22/p1=abc&p2=456&p3=ghi").should be_false
|
69
|
+
|
70
|
+
CACHE.expire_page(:key => "/cache_controller/action23/abc/456_and_ghi")
|
71
|
+
CACHE.cached_page?(:key => "/cache_controller/action23/abc/456_and_ghi").should be_false
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should expire all pages" do
|
75
|
+
CACHE.expire_all_pages
|
76
|
+
CACHE.cached_page?("action6").should be_false
|
77
|
+
Dir.glob(Merb::Controller._cache.config[:cache_html_directory] + '/*').should be_empty
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
describe "cache_page" do
|
2
|
+
|
3
|
+
it "should cache page (action5)" do
|
4
|
+
c = get("/cache_controller/action5")
|
5
|
+
c.body.strip.should == "test action5"
|
6
|
+
c.cached_page?("action5").should be_true
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should expire page (action5)" do
|
10
|
+
CACHE.expire_page("action5")
|
11
|
+
CACHE.cached_page?("action5").should be_false
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should cache page (action5) with full path" do
|
15
|
+
c = get("/cache_controller/action5/this/is/a/test")
|
16
|
+
c.cached_page?(:action => "action5", :params => %w(this is a test), :format => :tree).should be_true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should expire page (action5) with full path" do
|
20
|
+
CACHE.expire_page(:action => "action5",
|
21
|
+
:controller => "cache_controller",
|
22
|
+
:params => %w(this is a test))
|
23
|
+
CACHE.cached_page?(:key => "/cache_controller/action5/this/is/a/test").should be_false
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should cache page (action6), use it and expire 3 seconds after" do
|
27
|
+
CACHE.expire_page :match => true, :action => "action6"
|
28
|
+
c = get("/cache_controller/action6")
|
29
|
+
now = Time.now.to_s
|
30
|
+
c.body.strip.should == now
|
31
|
+
c.cached_page?("action6").should be_true
|
32
|
+
sleep 1
|
33
|
+
c = get("/cache_controller/action6")
|
34
|
+
c.body.strip.should == now
|
35
|
+
sleep 2
|
36
|
+
c = get("/cache_controller/action6")
|
37
|
+
c.body.strip.should == Time.now.to_s
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should cache page with full path (action6) and expire in 3 seconds" do
|
41
|
+
CACHE.expire_page "action6"
|
42
|
+
CACHE.cached_page?(:action => "action6", :params => %w(path to nowhere)).should be_false
|
43
|
+
c = get("/cache_controller/action6/path/to/nowhere/")
|
44
|
+
now = Time.now.to_s
|
45
|
+
c.body.strip.should == now
|
46
|
+
c.cached_page?(:action => "action6", :params => %w(path to nowhere), :format => :tree).should be_true
|
47
|
+
sleep 1
|
48
|
+
c = get("/cache_controller/action6/path/to/nowhere")
|
49
|
+
c.body.strip.should == now
|
50
|
+
sleep 2
|
51
|
+
c = get("/cache_controller/action6/path/to/nowhere")
|
52
|
+
c.body.strip.should == Time.now.to_s
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should expire page in many ways" do
|
56
|
+
c = get("/cache_controller/action6")
|
57
|
+
CACHE.expire_page("action6")
|
58
|
+
CACHE.cached_page?("action6").should be_false
|
59
|
+
|
60
|
+
c = get("/cache_controller/action6")
|
61
|
+
CACHE.expire_page(:match => "/cache_control")
|
62
|
+
CACHE.cached_page?(:action => "action6").should be_false
|
63
|
+
|
64
|
+
c = get("/cache_controller/action6")
|
65
|
+
CACHE.expire_page(:action => "action6")
|
66
|
+
CACHE.cached_page?(:action => "action6").should be_false
|
67
|
+
|
68
|
+
c = get("/cache_controller/action6/id1/id2")
|
69
|
+
CACHE.expire_page(:action => "action6", :params => %w(id1 id2))
|
70
|
+
CACHE.cached_page?(:action => "action6", :params => %w(id1 id2)).should be_false
|
71
|
+
|
72
|
+
c = get("/cache_controller/action6/id1/id2")
|
73
|
+
CACHE.expire_page(:action => "action6", :match => true)
|
74
|
+
CACHE.cached_page?(:action => "action6", :params => %w(id1 id2)).should be_false
|
75
|
+
|
76
|
+
c = get("/cache_controller/action6")
|
77
|
+
CACHE.expire_page(:action => "action6", :controller => "cache_controller")
|
78
|
+
CACHE.cached_page?(:action => "action6", :controller => "cache_controller").should be_false
|
79
|
+
|
80
|
+
c = get("/cache_controller/action6/id1/id2")
|
81
|
+
CACHE.expire_page(:action => "action6", :params => %w(id1), :match => true)
|
82
|
+
CACHE.cached_page?(:action => "action6", :params => %w(id1 id2)).should be_false
|
83
|
+
|
84
|
+
c = get("/cache_controller/action6/id1/id2")
|
85
|
+
CACHE.expire_page(:action => "action6", :controller => "cache_controller", :match => true)
|
86
|
+
CACHE.cached_page?(:action => "action6", :params => %w(id1 id2)).should be_false
|
87
|
+
|
88
|
+
c = get("/cache_controller/action6/id1/id2")
|
89
|
+
CACHE.expire_page(:action => "action6", :controller => "cache_controller", :params => %w(id1), :match => true)
|
90
|
+
CACHE.cached_page?(:action => "action6", :params => %w(id1 id2)).should be_false
|
91
|
+
|
92
|
+
c = get("/cache_controller/action6/id1/id2")
|
93
|
+
CACHE.expire_page(:action => "action6", :controller => "cache_controller", :params => %w(id1 id2))
|
94
|
+
CACHE.cached_page?(:action => "action6", :controller => "cache_controller", :params => %w(id1 id2)).should be_false
|
95
|
+
|
96
|
+
c = get("/cache_controller/action6")
|
97
|
+
CACHE.expire_page(:key => "/cache_controller/action6")
|
98
|
+
CACHE.cached_page?(:key => "/cache_controller/action6").should be_false
|
99
|
+
c = get("/cache_controller/action6/id1/id2")
|
100
|
+
CACHE.expire_page(:key => "/cache_controller/action6", :params => %w(id1 id2))
|
101
|
+
CACHE.cached_page?(:key => "/cache_controller/action6", :params => %w(id1 id2)).should be_false
|
102
|
+
|
103
|
+
c = get("/cache_controller/action6/id1/id2")
|
104
|
+
CACHE.expire_page(:key => "/cache_controller/action6/id1", :match => true)
|
105
|
+
CACHE.cached_page?(:key => "/cache_controller/action6/id1/id2").should be_false
|
106
|
+
|
107
|
+
c = get("/cache_controller/action6/id1/id2")
|
108
|
+
CACHE.expire_page(:key => "/cache_controller/action6", :params => %w(id1), :match => true)
|
109
|
+
CACHE.cached_page?(:key => "/cache_controller/action6/id1/id2").should be_false
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should respect original content-type" do
|
113
|
+
c = get("/cache_controller/action7.css")
|
114
|
+
c.body.should == "CSS"
|
115
|
+
c = get("/cache_controller/action7.css")
|
116
|
+
c.params[:format].should == "css"
|
117
|
+
c.cached_page?(:action => "action7", :extension => 'css').should be_true
|
118
|
+
|
119
|
+
c = get("/cache_controller/action7.js")
|
120
|
+
c.body.should == "JS"
|
121
|
+
c = get("/cache_controller/action7.js")
|
122
|
+
c.params[:format].should == "js"
|
123
|
+
c.cached_page?(:action => "action7", :extension => 'js').should be_true
|
124
|
+
|
125
|
+
c = get("/cache_controller/action7.xml")
|
126
|
+
c.body.should == "XML"
|
127
|
+
c = get("/cache_controller/action7.xml")
|
128
|
+
c.params[:format].should == "xml"
|
129
|
+
c.cached_page?(:action => "action7", :extension => 'xml').should be_true
|
130
|
+
|
131
|
+
c = get("/cache_controller/action7.jpg")
|
132
|
+
c.body.should == "JPG"
|
133
|
+
c = get("/cache_controller/action7.jpg")
|
134
|
+
c.params[:format].should == "jpg"
|
135
|
+
c.cached_page?(:action => "action7", :extension => 'jpg').should be_true
|
136
|
+
|
137
|
+
c = get("/cache_controller/action7.html")
|
138
|
+
c.body.should == "HTML"
|
139
|
+
c = get("/cache_controller/action7.html")
|
140
|
+
c.params[:format].should == "html"
|
141
|
+
c.cached_page?(:action => "action7").should be_true
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should expire all pages" do
|
145
|
+
CACHE.expire_all_pages
|
146
|
+
CACHE.cached_page?("action6").should be_false
|
147
|
+
Dir.glob(Merb::Controller._cache.config[:cache_html_directory] + '/*').should be_empty
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
:development: &defaults
|
3
|
+
:adapter: sqlite3
|
4
|
+
:database: tmp/merb_cache_more.sqlite3
|
5
|
+
:log_stream: log/sql.log
|
6
|
+
:log_level: 0
|
7
|
+
|
8
|
+
:test:
|
9
|
+
<<: *defaults
|
10
|
+
:database: tmp/merb_cache_more.sqlite3
|
11
|
+
|
12
|
+
:production:
|
13
|
+
<<: *defaults
|
14
|
+
:database: tmp/merb_cache_more.sqlite3
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
Merb::Router.prepare do |r|
|
4
|
+
r.default_routes
|
5
|
+
r.match("/").to(:controller => "cache_controller", :action => "index")
|
6
|
+
end
|
7
|
+
|
8
|
+
CACHE = CacheController.new(Merb::Test::RequestHelper::FakeRequest.new)
|
9
|
+
CACHE.expire_all
|
10
|
+
|
11
|
+
puts "Using #{CACHE._cache.store.cache_store_type.inspect} store"
|
12
|
+
|
13
|
+
require "cache_keys_spec"
|
14
|
+
require "cache_action_spec"
|
15
|
+
require "cache_action_params_spec"
|
16
|
+
require "cache_page_spec"
|
17
|
+
require "cache_page_params_spec"
|
18
|
+
require "cache_fragment_spec"
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
$TESTING=true
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
3
|
+
|
4
|
+
require "rubygems"
|
5
|
+
require "merb-core"
|
6
|
+
require "merb-haml"
|
7
|
+
require "fileutils"
|
8
|
+
require "merb-core/test"
|
9
|
+
require "merb_cache_more"
|
10
|
+
require File.dirname(__FILE__) / "cache_controller"
|
11
|
+
|
12
|
+
def set_database_adapter(adapter)
|
13
|
+
config_file = File.dirname(__FILE__) / "config/database.yml"
|
14
|
+
config = IO.read(config_file)
|
15
|
+
config.gsub!(/:adapter:\s+.*$/, ":adapter: #{adapter}")
|
16
|
+
File.open(config_file, "w+") do |c| c.write(config) end
|
17
|
+
end
|
18
|
+
|
19
|
+
def use_cache_store(store, orm = nil)
|
20
|
+
Merb::Plugins.config[:merb_cache] = {
|
21
|
+
:store => store,
|
22
|
+
:cache_directory => File.dirname(__FILE__) / "tmp/cache",
|
23
|
+
:cache_html_directory => File.dirname(__FILE__) / "tmp/html",
|
24
|
+
}
|
25
|
+
FileUtils.rm_rf(Dir.glob(File.dirname(__FILE__) / "/tmp"))
|
26
|
+
case store
|
27
|
+
when "dummy"
|
28
|
+
when "file"
|
29
|
+
when "memory"
|
30
|
+
when "memcache"
|
31
|
+
require "memcache"
|
32
|
+
when "database"
|
33
|
+
case orm
|
34
|
+
when "datamapper"
|
35
|
+
Merb.environment = "test"
|
36
|
+
Merb.logger = Merb::Logger.new("log/merb_test.log")
|
37
|
+
set_database_adapter("sqlite3")
|
38
|
+
require "merb_datamapper"
|
39
|
+
when "activerecord"
|
40
|
+
Merb.logger = Merb::Logger.new("log/merb_test.log")
|
41
|
+
set_database_adapter("sqlite3")
|
42
|
+
require "merb_activerecord"
|
43
|
+
when "sequel"
|
44
|
+
set_database_adapter("sqlite")
|
45
|
+
require "merb_sequel"
|
46
|
+
else
|
47
|
+
raise "Unknown orm: #{orm}"
|
48
|
+
end
|
49
|
+
else
|
50
|
+
raise "Unknown cache store: #{store}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
store = "file"
|
55
|
+
case ENV["STORE"] || store
|
56
|
+
when "file"
|
57
|
+
use_cache_store "file"
|
58
|
+
when "memory"
|
59
|
+
use_cache_store "memory"
|
60
|
+
when "memcache"
|
61
|
+
use_cache_store "memcache"
|
62
|
+
when "datamapper"
|
63
|
+
use_cache_store "database", "datamapper"
|
64
|
+
when "sequel"
|
65
|
+
use_cache_store "database", "sequel"
|
66
|
+
when "activerecord"
|
67
|
+
use_cache_store "database", "activerecord"
|
68
|
+
when "dummy"
|
69
|
+
use_cache_store "dummy"
|
70
|
+
else
|
71
|
+
puts "Invalid cache store: #{ENV["store"]}"
|
72
|
+
exit
|
73
|
+
end
|
74
|
+
|
75
|
+
FileUtils.mkdir_p(Merb::Plugins.config[:merb_cache][:cache_html_directory])
|
76
|
+
FileUtils.mkdir_p(Merb::Plugins.config[:merb_cache][:cache_directory])
|
77
|
+
|
78
|
+
Merb.start :environment => "test", :adapter => "runner"
|
79
|
+
|
80
|
+
Spec::Runner.configure do |config|
|
81
|
+
config.include Merb::Test::RequestHelper
|
82
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bchiu-merb_cache_more
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Chiu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-06-02 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: merb-core
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.9.4
|
23
|
+
version:
|
24
|
+
description: Extends merb-cache to use params, work with pagination, auto-cache all actions and use many key formats
|
25
|
+
email: bchiu@yahoo.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README
|
32
|
+
- LICENSE
|
33
|
+
- TODO
|
34
|
+
files:
|
35
|
+
- LICENSE
|
36
|
+
- README
|
37
|
+
- Rakefile
|
38
|
+
- TODO
|
39
|
+
- lib/merb_cache_more
|
40
|
+
- lib/merb_cache_more/cache-action.rb
|
41
|
+
- lib/merb_cache_more/cache-fragment.rb
|
42
|
+
- lib/merb_cache_more/cache-page.rb
|
43
|
+
- lib/merb_cache_more/cache-store
|
44
|
+
- lib/merb_cache_more/cache-store/database-activerecord.rb
|
45
|
+
- lib/merb_cache_more/cache-store/database-datamapper.rb
|
46
|
+
- lib/merb_cache_more/cache-store/database-sequel.rb
|
47
|
+
- lib/merb_cache_more/cache-store/database.rb
|
48
|
+
- lib/merb_cache_more/cache-store/dummy.rb
|
49
|
+
- lib/merb_cache_more/cache-store/file.rb
|
50
|
+
- lib/merb_cache_more/cache-store/memcache.rb
|
51
|
+
- lib/merb_cache_more/cache-store/memory.rb
|
52
|
+
- lib/merb_cache_more/merb-cache.rb
|
53
|
+
- lib/merb_cache_more/merbtasks.rb
|
54
|
+
- lib/merb_cache_more/request.rb
|
55
|
+
- lib/merb_cache_more/request_helper.rb
|
56
|
+
- lib/merb_cache_more.rb
|
57
|
+
- spec/cache_action_params_spec.rb
|
58
|
+
- spec/cache_action_spec.rb
|
59
|
+
- spec/cache_controller.rb
|
60
|
+
- spec/cache_fragment_spec.rb
|
61
|
+
- spec/cache_keys_spec.rb
|
62
|
+
- spec/cache_page_params_spec.rb
|
63
|
+
- spec/cache_page_spec.rb
|
64
|
+
- spec/config
|
65
|
+
- spec/config/database.yml
|
66
|
+
- spec/merb_cache_more_spec.rb
|
67
|
+
- spec/spec_helper.rb
|
68
|
+
- spec/views
|
69
|
+
- spec/views/cache_controller
|
70
|
+
- spec/views/cache_controller/action1.html.erb
|
71
|
+
- spec/views/cache_controller/action2.html.haml
|
72
|
+
has_rdoc: true
|
73
|
+
homepage: http://github.com/bchiu/merb_cache_more
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: "0"
|
84
|
+
version:
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: "0"
|
90
|
+
version:
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 1.0.1
|
95
|
+
signing_key:
|
96
|
+
specification_version: 2
|
97
|
+
summary: Extends merb-cache to use params, work with pagination, auto-cache all actions and use many key formats
|
98
|
+
test_files: []
|
99
|
+
|