kaminari-cache 0.2.1 → 0.2.2
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/kaminari-cache.gemspec +1 -1
- data/lib/kaminari-cache.rb +18 -14
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe0585f499877dc7c90c86a7846b9aaee148974d
|
|
4
|
+
data.tar.gz: da3a8d4d8619676d20ceaf9b75ebe311a278741d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dabb4782cb9e18a7058a44e2ab41c4a749613456eba67c6fd7e3c3de5e3b1a87a06e93115dc0b0c752a5dd9b79e1fa66f228f59891f815acb5da5ba2d556ff17
|
|
7
|
+
data.tar.gz: 6eb38ef73808579226c561f460689c3c336b3a8bd74767e3ed9f9e156c20e6709ac10836f2a0880c43ef00f0ba5bf96d593fd5ab8c976671e62d9ec82a2f20cd
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.2
|
data/kaminari-cache.gemspec
CHANGED
data/lib/kaminari-cache.rb
CHANGED
|
@@ -6,27 +6,31 @@ module KaminariCache
|
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def flush_pagination_cache
|
|
9
|
-
store_class = Rails.cache.class.name.split("::").last
|
|
9
|
+
@store_class = Rails.cache.class.name.split("::").last
|
|
10
10
|
if Rails.cache.respond_to? "delete_matched"
|
|
11
11
|
|
|
12
12
|
self.changed.each do |field|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Rails.logger.info "Cache flush: #{match.join}"
|
|
16
|
-
case store_class
|
|
17
|
-
when "DalliStore"
|
|
18
|
-
# DalliStore uses a Regexp
|
|
19
|
-
regexp = Regexp.new match.join.gsub(/\*/,'.*?')
|
|
20
|
-
Rails.cache.delete_matched /^#{Regexp.escape(:kaminari)}\/#{Regexp.escape(self.class.name.downcase)}/
|
|
21
|
-
when "RedisStore"
|
|
22
|
-
# RedisStore uses a String
|
|
23
|
-
Rails.cache.delete_matched match.join
|
|
24
|
-
end
|
|
13
|
+
flush_match [:kaminari, "/#{self.class.name.downcase}", '*', "/#{:order}", '*', "/#{field}", '*']
|
|
25
14
|
end
|
|
15
|
+
# flush scoped pagings...
|
|
16
|
+
flush_match [:kaminari, "/#{self.class.name.downcase}", '*', "/#{:scope}", '*']
|
|
26
17
|
|
|
27
18
|
else
|
|
28
19
|
Rails.cache.clear
|
|
29
|
-
Rails.logger.warn "#{store_class} does not support deleting matched keys. The entire cache was flushed. Consider using RedisStore (Redis) OR DalliStore (gem dalli) for memcached with dalli-store-extensions gem for improved performance."
|
|
20
|
+
Rails.logger.warn "#{@store_class} does not support deleting matched keys. The entire cache was flushed. Consider using RedisStore (Redis) OR DalliStore (gem dalli) for memcached with dalli-store-extensions gem for improved performance."
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def flush_match(match)
|
|
25
|
+
Rails.logger.info "Cache flush: #{match.join}"
|
|
26
|
+
case @store_class
|
|
27
|
+
when "DalliStore"
|
|
28
|
+
# DalliStore uses a Regexp
|
|
29
|
+
regexp = Regexp.new match.join.gsub(/\*/,'.*?')
|
|
30
|
+
Rails.cache.delete_matched /^#{Regexp.escape(:kaminari)}\/#{Regexp.escape(self.class.name.downcase)}/
|
|
31
|
+
when "RedisStore"
|
|
32
|
+
# RedisStore uses a String
|
|
33
|
+
Rails.cache.delete_matched match.join
|
|
30
34
|
end
|
|
31
35
|
end
|
|
32
36
|
|