tagged-cache 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.1.0 2010-11-02
2
+
3
+ * TaggedCache supports ActionController#caches_action now.
4
+
1
5
  === 1.0.4 2010-10-14
2
6
 
3
7
  * Fixed bug: Dalli requires :raw => true option in #read_multi.
data/README.rdoc CHANGED
@@ -58,6 +58,44 @@ ActiveSupport cache adapter with tagged dependencies.
58
58
  [obj1, obj2]
59
59
  end
60
60
 
61
+ === RAILS EXAMPLE:
62
+
63
+ # config/environments/production.rb:
64
+ Rails3::Application.configure do
65
+ ...
66
+ config.cache_store = :tagged_store, { :tag_store => [:mem_cache_store, %w(localhost), { :namespace => "tags" }], :entity_store => [:mem_cache_store, %w(localhost), { :namespace => "entities" }] }
67
+ ...
68
+ end
69
+
70
+ # app/controller/samples_controller.rb:
71
+ class SamplesController < ApplicationController
72
+ # specify :depends using lambda
73
+ caches_action :show, :depends => lambda { |c|
74
+ c.instance_eval do
75
+ # @sample must respond to #cache_tag method
76
+ [@sample]
77
+ end
78
+ }
79
+
80
+ # specify :depends using method name
81
+ caches_action :index, :depends => :index_tags
82
+
83
+ def index
84
+ @samples = Sample.all
85
+ end
86
+
87
+ def show
88
+ @sample = Sample.find(params[:id])
89
+ end
90
+
91
+ private
92
+
93
+ def index_tags
94
+ # each element of @samples must respond to #cache_tag method
95
+ @samples
96
+ end
97
+ end
98
+
61
99
  == REQUIREMENTS:
62
100
 
63
101
  * activesupport >= 3.0.0
@@ -0,0 +1,5 @@
1
+ require "active_support"
2
+
3
+ ActiveSupport.on_load(:action_controller) do
4
+ require "tagged-cache/action_controller"
5
+ end
@@ -0,0 +1,20 @@
1
+ module ActionController
2
+ module Caching
3
+ module Actions
4
+ def _save_fragment_with_options_processing(name, options)
5
+ depends = options[:depends]
6
+ depends = if depends.is_a?(Symbol)
7
+ send(depends)
8
+ elsif depends.respond_to?(:call)
9
+ instance_exec(self, &depends)
10
+ else
11
+ depends
12
+ end
13
+ _save_fragment_without_options_processing(name, options.merge(:depends => depends))
14
+ end
15
+
16
+ alias_method_chain :_save_fragment, :options_processing
17
+ end
18
+ end
19
+ end
20
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tagged-cache
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 4
10
- version: 1.0.4
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Anton Ageev
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-14 00:00:00 +04:00
18
+ date: 2010-11-02 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -47,6 +47,8 @@ files:
47
47
  - History.txt
48
48
  - Rakefile
49
49
  - lib/active_support/cache/tagged_store.rb
50
+ - lib/tagged-cache.rb
51
+ - lib/tagged-cache/action_controller.rb
50
52
  - spec/tagged_store_spec.rb
51
53
  - spec/spec_helper.rb
52
54
  has_rdoc: true