varnish_sweeper 0.1.1 → 0.2.0

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/README.rdoc CHANGED
@@ -1,6 +1,10 @@
1
1
  = varnish_sweeper
2
2
 
3
- Description goes here.
3
+ sweep_cache_for(@obj, :instant => false, :urls => ["urla","urlb"])
4
+
5
+ options :
6
+ * :instant = false > enqueue in resque , true > instant sweep
7
+ * :urls = additional urls to sweep
4
8
 
5
9
  == Contributing to varnish_sweeper
6
10
 
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ Jeweler::Tasks.new do |gem|
18
18
  gem.summary = %Q{A few helper functions that help caching and sweeping web pages using varnish}
19
19
  gem.description = %Q{A few helper functions that help caching and sweeping web pages using varnish}
20
20
  gem.email = "developers@moviepilot.com"
21
- gem.authors = ["Daniel Bornkessel", "Tim Bleck"]
21
+ gem.authors = ["Daniel Bornkessel", "Tim Bleck", "Helmut Ebritsch", "Christoph Grabo"]
22
22
  # Include your dependencies below. Runtime dependencies are required when using your gem,
23
23
  # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
24
  # gem.add_runtime_dependency 'jabber4r', '> 0.1'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
data/lib/varnish.rb CHANGED
@@ -12,12 +12,14 @@ module Varnish
12
12
 
13
13
  def sweep_cache_for(obj, options = {})
14
14
  return unless obj
15
+ # cache_data is a frozen hash
15
16
  if cache_data = Rails.cache.read( varnish_cache_key(obj) )
16
17
  Rails.cache.delete( varnish_cache_key(obj) )
18
+ urls = cache_data[:urls] + options[:urls].to_a
17
19
  if options[:instant]
18
- SweeperJob.perform(cache_data[:urls])
20
+ SweeperJob.perform(urls)
19
21
  else
20
- Resque.enqueue(SweeperJob, cache_data[:urls])
22
+ Resque.enqueue(SweeperJob, urls)
21
23
  end
22
24
  end
23
25
  end
@@ -54,6 +54,20 @@ describe Varnish do
54
54
  end
55
55
 
56
56
  end
57
+
58
+ context 'sweeping a defined urls (with option :urls => [url,url])' do
59
+
60
+ it "should sweep normal cache + optional urls" do
61
+ SweeperJob.should_receive(:perform).with(["cached_url"]+["urla","urlb"])
62
+ @controller.sweep_cache_for(@obj, :instant => true, :urls => ["urla","urlb"])
63
+ end
64
+
65
+ it "should sweep normal cache + optional urls" do
66
+ Resque.should_receive(:enqueue).with(SweeperJob, ["cached_url"]+["urla","urlb"])
67
+ @controller.sweep_cache_for(@obj, :instant => false, :urls => ["urla","urlb"])
68
+ end
69
+
70
+ end
57
71
 
58
72
  end
59
73
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{varnish_sweeper}
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Daniel Bornkessel", "Tim Bleck"]
12
- s.date = %q{2011-03-31}
11
+ s.authors = ["Daniel Bornkessel", "Tim Bleck", "Helmut Ebritsch", "Christoph Grabo"]
12
+ s.date = %q{2011-04-12}
13
13
  s.description = %q{A few helper functions that help caching and sweeping web pages using varnish}
14
14
  s.email = %q{developers@moviepilot.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,22 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: varnish_sweeper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Bornkessel
14
14
  - Tim Bleck
15
+ - Helmut Ebritsch
16
+ - Christoph Grabo
15
17
  autorequire:
16
18
  bindir: bin
17
19
  cert_chain: []
18
20
 
19
- date: 2011-03-31 00:00:00 +02:00
21
+ date: 2011-04-12 00:00:00 +02:00
20
22
  default_executable:
21
23
  dependencies:
22
24
  - !ruby/object:Gem::Dependency