varnish_sweeper 0.2.0 → 0.2.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 +1 -1
- data/lib/varnish.rb +7 -2
- data/spec/varnish_sweeper/varnish_spec.rb +23 -0
- data/varnish_sweeper.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/varnish.rb
CHANGED
@@ -13,9 +13,14 @@ module Varnish
|
|
13
13
|
def sweep_cache_for(obj, options = {})
|
14
14
|
return unless obj
|
15
15
|
# cache_data is a frozen hash
|
16
|
-
if cache_data = Rails.cache.read( varnish_cache_key(obj)
|
16
|
+
if (cache_data = Rails.cache.read( varnish_cache_key(obj))) || options[:urls]
|
17
17
|
Rails.cache.delete( varnish_cache_key(obj) )
|
18
|
-
|
18
|
+
if cache_data
|
19
|
+
urls = cache_data[:urls].to_a + options[:urls].to_a
|
20
|
+
else
|
21
|
+
urls = options[:urls].to_a
|
22
|
+
end
|
23
|
+
|
19
24
|
if options[:instant]
|
20
25
|
SweeperJob.perform(urls)
|
21
26
|
else
|
@@ -70,5 +70,28 @@ describe Varnish do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
end
|
73
|
+
|
74
|
+
describe :sweep_cache_for do
|
75
|
+
|
76
|
+
before do
|
77
|
+
@obj = mock('Model')
|
78
|
+
@controller.stub!(:varnish_cache_key).with(@obj).and_return("cache_key")
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'sweeping a defined urls (with option :urls => [url,url])' do
|
82
|
+
|
83
|
+
it "should sweep normal cache + optional urls" do
|
84
|
+
SweeperJob.should_receive(:perform).with(["urla","urlb"])
|
85
|
+
@controller.sweep_cache_for(@obj, :instant => true, :urls => ["urla","urlb"])
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should sweep normal cache + optional urls" do
|
89
|
+
Resque.should_receive(:enqueue).with(SweeperJob, ["urla","urlb"])
|
90
|
+
@controller.sweep_cache_for(@obj, :instant => false, :urls => ["urla","urlb"])
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
73
96
|
|
74
97
|
end
|
data/varnish_sweeper.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{varnish_sweeper}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Daniel Bornkessel", "Tim Bleck", "Helmut Ebritsch", "Christoph Grabo"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: varnish_sweeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Bornkessel
|