redis-cache 1.0.0 → 1.0.1

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.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.0.1 2011-07-18
2
+
3
+ * Fixed bug: #increment and #decrement should respect :expires_in option.
4
+
1
5
  === 1.0.0 2011-07-09
2
6
 
3
7
  * Bump up version. First stable release.
@@ -29,16 +29,26 @@ module ActiveSupport
29
29
 
30
30
  def increment(name, amount = 1, options = nil)
31
31
  options = merged_options(options)
32
+ expires_in = options[:expires_in].to_i
32
33
  response = instrument(:increment, name, :amount => amount) do
33
- @redis.incrby(namespaced_key(name, options), amount)
34
+ r = @redis.incrby(namespaced_key(name, options), amount)
35
+ if expires_in > 0
36
+ @redis.expire(namespaced_key(name, options), expires_in)
37
+ end
38
+ r
34
39
  end
35
40
  response
36
41
  end
37
42
 
38
43
  def decrement(name, amount = 1, options = nil)
39
44
  options = merged_options(options)
45
+ expires_in = options[:expires_in].to_i
40
46
  response = instrument(:decrement, name, :amount => amount) do
41
- @redis.decrby(namespaced_key(name, options), amount)
47
+ r = @redis.decrby(namespaced_key(name, options), amount)
48
+ if expires_in > 0
49
+ @redis.expire(namespaced_key(name, options), expires_in)
50
+ end
51
+ r
42
52
  end
43
53
  response
44
54
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: redis-cache
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Anton Ageev
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-09 00:00:00 Z
13
+ date: 2011-07-18 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport