redis_page 0.1.12 → 0.1.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12fe8841ebb2226842483c46aefb06112e0d47b9
4
- data.tar.gz: c9eb24aaba8f066cb27a104769482f6c1d75fd4f
3
+ metadata.gz: a088b6a3ec3e6a1563e013443b295c0c5230bfeb
4
+ data.tar.gz: 8da5a745b6b7d0da62b07b7df5fd7ae6637686e7
5
5
  SHA512:
6
- metadata.gz: af2dcd6a121d123001c696c6b23e27549680df8a4d82296fb844e08cedc1ea4946da7ef941b00d5c5279744870a4876f1fa84bc9a3061907a36a8cc348c059ea
7
- data.tar.gz: 40663eda1b7f8bdcaa03a73d15e7902b3e4f015e001eab6b34a83598ad7b0626581384cf50a445425ac9b1a15ab2fcd84604b8d27e1f570027a61254d29ae91f
6
+ metadata.gz: e2289e88d5575cb51131e9ace9583f4195375dca7f6e0893dec2b8e11c40092e1cd2672b7cbc533220a94339025048992b7d3827b7d35e4dcc1e9e9b3093b4f7
7
+ data.tar.gz: a1025822fc3f1a5122295e059d786cb64a2ed399bfa65ed19a79224d1181995ef2119f3d35fe04aa3c536080ead936b6654084d2ed843b524977e88c87ff6449
data/README.md CHANGED
@@ -52,6 +52,7 @@ class ProductController < ActionController::Base
52
52
  caches_redis_page :show # 或者使用下面两行的格式
53
53
  #caches_redis_page :show, append_country: true # cache key 会在 path 后面加上国家代码,例如:/products-US
54
54
  #caches_redis_page :show, unless: Proc.new { params[:preview] } # 带上 preview 参数,则不进行缓存,方便管理员对未保存的内容进行预览
55
+ #caches_redis_page :show, namespace: 'www' # 多个子域名的 path 可能相同,可以使用 namespace 来区分
55
56
 
56
57
  def show
57
58
  @product = Product.find(params[:id])
@@ -24,17 +24,24 @@ module ActionController
24
24
  end
25
25
 
26
26
  after_filter({only: actions}.merge(options)) do |c|
27
- path = request.path
27
+ #path = request.path # fixed: /products/ 地址带了/符号,缓存不生效
28
+ path = URI(request.original_url).path
28
29
  path = "#{path}-#{@cache_country}" if @cache_country
29
- c.cache_redis_page(response.body, path)
30
+ c.cache_redis_page(response.body, path, options)
30
31
  c.record_cached_page
31
32
  end
32
33
  end
33
34
  end
34
35
 
35
- def cache_redis_page(content, path)
36
- Rails.logger.info "[page cache]caching: #{path}"
37
- RedisPage.redis.setex(path, RedisPage.config.ttl || 604800, content) # 1 周后失效
36
+ def cache_redis_page(content, path, options = {})
37
+ key = path
38
+ text = "[page cache]caching: #{path}"
39
+ if namespace = options[:namespace]
40
+ key = "#{namespace}:#{key}"
41
+ text = "#{text} in #{namespace}"
42
+ end
43
+ Rails.logger.info text
44
+ RedisPage.redis.setex(key, RedisPage.config.ttl || 604800, content) # 1 周后失效
38
45
  end
39
46
 
40
47
  def record_cached_page
@@ -1,3 +1,3 @@
1
1
  module RedisPage
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.13"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_page
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - saberma
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-16 00:00:00.000000000 Z
11
+ date: 2015-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport