redis-cache 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8fc89339ef94cfa01df27ea4a78b497e18ce491e
4
+ data.tar.gz: 43f97830f02055dafd9365a05aa6dbceac139106
5
+ SHA512:
6
+ metadata.gz: db6f35e482dfdb920ac4b8717e0526e5cbf7c0891b28677cc0ee02be5445689ffa2f0fd1570c5b732c6bcdeba2e30c466053fc70eb5e6bad1bf249dc34332789
7
+ data.tar.gz: 9c4fad28e43135e4d2a61af629fe4eb3b47fa9c2756f0ba17b02728faf656b075bafe3090133b05574fe679de1b7389decac581add97a06e782a3fa1a1ae5c14
@@ -1,3 +1,7 @@
1
+ === 1.0.2 2013-07-07
2
+
3
+ * Added Rails 4 support.
4
+
1
5
  === 1.0.1 2011-07-18
2
6
 
3
7
  * Fixed bug: #increment and #decrement should respect :expires_in option.
data/Rakefile CHANGED
@@ -3,5 +3,7 @@ Bundler::GemHelper.install_tasks
3
3
 
4
4
  require "rspec/core/rake_task"
5
5
 
6
+ task :default => [:spec]
7
+
6
8
  desc "Run all examples"
7
9
  RSpec::Core::RakeTask.new(:spec)
@@ -16,6 +16,10 @@ module ActiveSupport
16
16
  options = { :logger => self.class.logger }.merge(options || {})
17
17
  @redis = ::Redis.new(options)
18
18
 
19
+ if (@redis.info["redis_version"].split(".").map { |x| x.to_i } <=> [2, 1, 3]) < 0
20
+ $stderr.puts "Redis server with version < 2.1.3 has bug with increment/decrement on values with expiring time! Please upgrade Redis server or don't use increment/decrement methods with :expires_in option."
21
+ end
22
+
19
23
  extend Strategy::LocalCache
20
24
  end
21
25
 
@@ -30,10 +34,11 @@ module ActiveSupport
30
34
  def increment(name, amount = 1, options = nil)
31
35
  options = merged_options(options)
32
36
  expires_in = options[:expires_in].to_i
37
+ redis_key = namespaced_key(name, options)
33
38
  response = instrument(:increment, name, :amount => amount) do
34
- r = @redis.incrby(namespaced_key(name, options), amount)
39
+ r = @redis.incrby(redis_key, amount)
35
40
  if expires_in > 0
36
- @redis.expire(namespaced_key(name, options), expires_in)
41
+ @redis.expire(redis_key, expires_in)
37
42
  end
38
43
  r
39
44
  end
@@ -43,10 +48,11 @@ module ActiveSupport
43
48
  def decrement(name, amount = 1, options = nil)
44
49
  options = merged_options(options)
45
50
  expires_in = options[:expires_in].to_i
51
+ redis_key = namespaced_key(name, options)
46
52
  response = instrument(:decrement, name, :amount => amount) do
47
- r = @redis.decrby(namespaced_key(name, options), amount)
53
+ r = @redis.decrby(redis_key, amount)
48
54
  if expires_in > 0
49
- @redis.expire(namespaced_key(name, options), expires_in)
55
+ @redis.expire(redis_key, expires_in)
50
56
  end
51
57
  r
52
58
  end
@@ -107,7 +107,7 @@ describe "ActiveSupport::Cache::RedisStore" do
107
107
 
108
108
  context "with raw key 'abc' == 5" do
109
109
  before(:each) do
110
- store.write("abc", 5, :raw => true)
110
+ store.write("abc", 5, :raw => true, :expires_in => 1.hour)
111
111
  end
112
112
 
113
113
  it "#increment('abc', 2) should return 7 and change key 'abc' to 7" do
metadata CHANGED
@@ -1,105 +1,108 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: redis-cache
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Anton Ageev
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2011-07-18 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
11
+ date: 2013-07-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
16
14
  name: activesupport
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ~>
22
- - !ruby/object:Gem::Version
23
- version: "3.0"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
24
20
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: redis
28
21
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: redis
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
34
33
  version: 2.2.0
35
34
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: rspec
39
35
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
43
45
  - - ~>
44
- - !ruby/object:Gem::Version
45
- version: "2.6"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.13'
46
48
  type: :development
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: i18n
50
49
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
54
52
  - - ~>
55
- - !ruby/object:Gem::Version
56
- version: "0.6"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: i18n
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.6'
57
62
  type: :development
58
- version_requirements: *id004
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '0.6'
59
69
  description:
60
- email:
70
+ email:
61
71
  - antage@gmail.com
62
72
  executables: []
63
-
64
73
  extensions: []
65
-
66
74
  extra_rdoc_files: []
67
-
68
- files:
75
+ files:
69
76
  - README.rdoc
70
77
  - History.txt
71
78
  - Rakefile
72
79
  - lib/redis-cache.rb
73
80
  - lib/active_support/cache/redis_store.rb
74
- - spec/redis_store_spec.rb
75
81
  - spec/spec_helper.rb
82
+ - spec/redis_store_spec.rb
76
83
  homepage: https://github.com/antage/redis-cache
77
84
  licenses: []
78
-
85
+ metadata: {}
79
86
  post_install_message:
80
87
  rdoc_options: []
81
-
82
- require_paths:
88
+ require_paths:
83
89
  - lib
84
- required_ruby_version: !ruby/object:Gem::Requirement
85
- none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: "0"
90
- required_rubygems_version: !ruby/object:Gem::Requirement
91
- none: false
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: "0"
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
96
100
  requirements: []
97
-
98
101
  rubyforge_project:
99
- rubygems_version: 1.8.5
102
+ rubygems_version: 2.0.3
100
103
  signing_key:
101
- specification_version: 3
104
+ specification_version: 4
102
105
  summary: ActiveSupport cache adapter for Redis
103
- test_files:
104
- - spec/redis_store_spec.rb
106
+ test_files:
105
107
  - spec/spec_helper.rb
108
+ - spec/redis_store_spec.rb