redis_page 0.1.24 → 0.1.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fad800d7547d5b35b0836350d471b1e2d322732
4
- data.tar.gz: 516725e7a39182cc523023de228a85e7a7a684a0
3
+ metadata.gz: 8c2939bbe398ab23368f867cdfb38eafdc778dd0
4
+ data.tar.gz: 3a70dbd037184a5b8d2fb6b19aac7bf5c439ec7d
5
5
  SHA512:
6
- metadata.gz: 9b8ea7538652f7eb91eac25624fb848ff801ab8a6ce08144d924c5b8c0a5d80caaf5533615ab674a50aec219b842ffe90210026e062509cea63b100bdaf3d073
7
- data.tar.gz: a0a01404268ac04cb36cc0effa6bf36b26779a8ee51a91ded1dad8df8e931b2879393f52a2fc82c7842e0b4d8e4e6628420bcc091b09ebf66c6793c9515c1250
6
+ metadata.gz: 3d6b0b6b57dbacc9c5c741bb91e4714e64108e5fe0baa5fa715ddba9bdd6efcd2478737dda1d6a06dc5d34ad9c1c76dacef646f830a3432abef19e5252030a43
7
+ data.tar.gz: dd00b93b1ea23429f0c8b86f2937c5d9ca8fa340b524ea22cd4979a1082d20b22eaa2fff3321f590db2d53567276a3a2590951df94748ccecf45f9e79ef92745
@@ -44,18 +44,8 @@ module ActionController
44
44
  end
45
45
  end
46
46
 
47
- # TODO: 全球化部署时需要将一个页面写到多个redis上去,需要确保: 1. 写入速度快; 2. 确保写入成功;
48
47
  def cache_redis_page(content, path, options = {})
49
- key = path
50
- text = "[page cache]caching: #{path}"
51
- if namespace = options[:namespace]
52
- key = "#{namespace}:#{key}"
53
- text = "#{text} in #{namespace}"
54
- end
55
- Rails.logger.info text
56
- # RedisPage.cache_page_redis.setex(key, RedisPage.config.ttl || 604800, content) # 1 周后失效
57
- # 对于某个原本带有生存时间(TTL)的键来说, 当 SET 命令成功在这个键上执行时, 这个键原有的 TTL 将被清除。
58
- RedisPage.cache_page_redis.set(key, content) # 永不失效
48
+ RedisPage.page_content_writter.write(content, path, options)
59
49
  end
60
50
 
61
51
  def record_cached_page
@@ -1,3 +1,3 @@
1
1
  module RedisPage
2
- VERSION = '0.1.24'
2
+ VERSION = '0.1.25'
3
3
  end
@@ -0,0 +1,20 @@
1
+ module RedisPage
2
+ module Writter
3
+ class Base
4
+
5
+ def write(content, path, options = {})
6
+ key = path
7
+ text = "[page cache]caching: #{path}"
8
+ if namespace = options[:namespace]
9
+ key = "#{namespace}:#{key}"
10
+ text = "#{text} in #{namespace}"
11
+ end
12
+ Rails.logger.info text
13
+ # RedisPage.cache_page_redis.setex(key, RedisPage.config.ttl || 604800, content) # 1 周后失效
14
+ # 对于某个原本带有生存时间(TTL)的键来说, 当 SET 命令成功在这个键上执行时, 这个键原有的 TTL 将被清除。
15
+ RedisPage.cache_page_redis.set(key, content) # 永不失效
16
+ end
17
+
18
+ end
19
+ end
20
+ end
data/lib/redis_page.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  require 'redis_page/railtie'
2
+ require 'redis_page/writter/base'
2
3
 
3
4
  module RedisPage
4
5
  class Config
5
6
  attr_accessor :sweeper, :redis, :ttl
6
7
  attr_accessor :cache_page_redis, :cache_relation_redis
7
8
  attr_accessor :compress_method
9
+ attr_accessor :page_content_writter
8
10
  end
9
11
 
10
12
  def self.config
@@ -32,6 +34,10 @@ module RedisPage
32
34
  [:deflate, :gzip].include?(config.compress_method) ? config.compress_method : nil
33
35
  end
34
36
 
37
+ def self.page_content_writter
38
+ config.page_content_writter || RedisPage::Writter::Base.new
39
+ end
40
+
35
41
  def self.sweeper
36
42
  config.sweeper
37
43
  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.24
4
+ version: 0.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - saberma
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-13 00:00:00.000000000 Z
11
+ date: 2016-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -118,6 +118,7 @@ files:
118
118
  - lib/redis_page/sweeper_worker.rb
119
119
  - lib/redis_page/version.rb
120
120
  - lib/redis_page/view_helpers.rb
121
+ - lib/redis_page/writter/base.rb
121
122
  - redis_page.gemspec
122
123
  homepage: https://github.com/saberma/redis_page
123
124
  licenses: