manage_cache 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/manage_cache/version.rb +1 -1
- data/lib/manage_cache.rb +24 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d086284c04b727bf43511670bb8e88bc4848e8c1
|
4
|
+
data.tar.gz: fefd47861d23256b765a6d4ff9fa07034ea1e833
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4831115ab6e9f5a6331c17a55f656afe9fb08f3b67e310c32698884ac7dfc42adc16c93cb52a05d2f979c97ecb16d310c14b7ec0a54f5cb4f8bdbac50639249e
|
7
|
+
data.tar.gz: f377bae3bc05679acd25c5ac3a9d368150a6481a7af0116ff9ab01a183d2296045ba6fc13ca77b6ab23e80ef289a522d930af5fe591c795b92aabc638e5e54a5
|
data/lib/manage_cache/version.rb
CHANGED
data/lib/manage_cache.rb
CHANGED
@@ -23,19 +23,14 @@ module ManageCache
|
|
23
23
|
module LocalInstanceMethods
|
24
24
|
def dump_cache!
|
25
25
|
self.class.cache_keys_specs.each do |key_name, key_specs|
|
26
|
-
|
27
|
-
# adds some extras to the cache key.
|
28
|
-
# To run with this gem, you have to add 'skip_digest: true'.
|
29
|
-
# Any other options will prevent correct cache deletion!!
|
30
|
-
#
|
31
|
-
[cache_key_for(key_name), "views/#{cache_key_for(key_name)}"].each do |key|
|
26
|
+
if delete_cache?(key_specs)
|
32
27
|
if !key_specs[:regexp].blank?
|
33
|
-
delete_cache_w_regexp(
|
28
|
+
delete_cache_w_regexp(key_name)
|
29
|
+
#delete_cache_w_regexp(key, key_specs)
|
34
30
|
else
|
35
|
-
Rails.cache.delete(key)
|
36
31
|
end
|
37
32
|
instance_variable_set("@cache_key_for_#{key_name}", nil)
|
38
|
-
end
|
33
|
+
end
|
39
34
|
end
|
40
35
|
end
|
41
36
|
|
@@ -129,11 +124,29 @@ module ManageCache
|
|
129
124
|
#
|
130
125
|
# be aware, that the matcher_string has to be escaped (e.g. "\\d+" instead of "\d+")!
|
131
126
|
#
|
132
|
-
def delete_cache_w_regexp(
|
133
|
-
|
127
|
+
def delete_cache_w_regexp(key_name)
|
128
|
+
specs = self.class.cache_keys_specs[key_name]
|
129
|
+
|
130
|
+
regexp = specs[:regexp].inject([]) do |m, (k,v)|
|
131
|
+
redis_store = Rails.cache.class == ActiveSupport::Cache::RedisStore
|
132
|
+
m << "#{k}=#{redis_store ? '*' : v}"
|
133
|
+
end.join('-')
|
134
|
+
|
135
|
+
key = prepare_cache_key(key_name)
|
134
136
|
Rails.cache.delete_matched("#{Regexp.escape(key)}-#{regexp}")
|
135
137
|
end
|
136
138
|
|
139
|
+
# the rails helper method 'cache (name, opts) do ...'
|
140
|
+
# adds some extras to the cache key.
|
141
|
+
# To run with this gem, you have to add 'skip_digest: true'.
|
142
|
+
# Any other options will prevent correct cache deletion!!
|
143
|
+
#
|
144
|
+
def delete_cache(key_name)
|
145
|
+
[cache_key_for(key_name), "views/#{cache_key_for(key_name)}"].each do |key|
|
146
|
+
Rails.cache.delete(key)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
137
150
|
# if some attributes are specified in :if_changed
|
138
151
|
# check whether they changed
|
139
152
|
# and delete cache only if they changed
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manage_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cgregor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|