tagged-cache 1.0.4 → 1.1.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/History.txt +4 -0
- data/README.rdoc +38 -0
- data/lib/tagged-cache.rb +5 -0
- data/lib/tagged-cache/action_controller.rb +20 -0
- metadata +6 -4
data/History.txt
CHANGED
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
|
data/lib/tagged-cache.rb
ADDED
@@ -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:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
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-
|
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
|