aub-cache_advance 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +47 -0
- data/cache_advance.gemspec +1 -1
- data/lib/cache_advance/named_cache.rb +5 -5
- metadata +1 -1
data/README.textile
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
h1. cache advance
|
2
|
+
|
3
|
+
CacheAdvance is a wrapper around the Rails caching system that provides a simple, centralized
|
4
|
+
configuration file for defining caches and an even simpler way to apply them.
|
5
|
+
|
6
|
+
Written by "Aubrey Holland":mailto:aubreyholland@gmail.com.
|
7
|
+
|
8
|
+
h3. download
|
9
|
+
|
10
|
+
Github: "Page":http://github.com/aub/cache_advance/tree/master
|
11
|
+
|
12
|
+
Gem: <pre>gem install aub-cache_advance --source http://gems.github.com</pre>
|
13
|
+
|
14
|
+
Note: if you install using the gem from Github, you'll need this
|
15
|
+
in your environment.rb if you want to use Rails 2.1's dependency manager:
|
16
|
+
|
17
|
+
<pre><code>
|
18
|
+
config.gem 'aub-cache_advance', :lib => 'cache_advance', :source => 'http://gems.github.com'
|
19
|
+
</code></pre>
|
20
|
+
|
21
|
+
h3. cache definition
|
22
|
+
|
23
|
+
Caches are defined in the file config/caches.rb, which will be loaded automatically by the gem.
|
24
|
+
This file is similar in format to the rails routes config file, allowing you to specify named
|
25
|
+
caches and configure their keys and how they will be expired.
|
26
|
+
|
27
|
+
<pre><code>
|
28
|
+
CacheAdvance::Caches.define_caches do |config|
|
29
|
+
|
30
|
+
config.qualifier(:params) do |request|
|
31
|
+
request.params
|
32
|
+
end
|
33
|
+
|
34
|
+
config.plugin :template_handler_observer_cache_plugin
|
35
|
+
|
36
|
+
config.content_block :expiration_time => 10.minutes, :qualifiers => [ :subdomain, :params ]
|
37
|
+
|
38
|
+
config.change_towns_all :expiration_types => [ :publication ]
|
39
|
+
config.change_towns_limited :expiration_types => [ :publication ]
|
40
|
+
|
41
|
+
config.publication_twitter_update :expiration_time => 10.minutes, :qualifiers => [ :subdomain ]
|
42
|
+
|
43
|
+
config.weather_widget :expiration_time => 10.minutes, :qualifiers => [ :subdomain ]
|
44
|
+
end
|
45
|
+
</code></pre>
|
46
|
+
|
47
|
+
..............More later.
|
data/cache_advance.gemspec
CHANGED
@@ -26,14 +26,14 @@ module CacheAdvance
|
|
26
26
|
key = key_for(request, options[:key])
|
27
27
|
|
28
28
|
if (cache = @cache.read(key))
|
29
|
-
call_plugins('after_read', key, request)
|
29
|
+
call_plugins('after_read', key, request, cache)
|
30
30
|
return cache
|
31
31
|
end
|
32
32
|
|
33
|
-
call_plugins('before_write', key, request)
|
34
33
|
result = block.call
|
34
|
+
call_plugins('before_write', key, request, cache)
|
35
35
|
@cache.write(key, result, rails_options)
|
36
|
-
call_plugins('after_write', key, request)
|
36
|
+
call_plugins('after_write', key, request, cache)
|
37
37
|
|
38
38
|
add_to_cached_keys_list(key)
|
39
39
|
|
@@ -75,8 +75,8 @@ module CacheAdvance
|
|
75
75
|
|
76
76
|
protected
|
77
77
|
|
78
|
-
def call_plugins(method, key, request)
|
79
|
-
@cache_set.plugins.each { |p| p.send(method, @name, key, request) if p.respond_to?(method) }
|
78
|
+
def call_plugins(method, key, request, data)
|
79
|
+
@cache_set.plugins.each { |p| p.send(method, @name, key, request, data) if p.respond_to?(method) }
|
80
80
|
end
|
81
81
|
|
82
82
|
def add_to_cached_keys_list(key)
|