redis-cluster-activesupport 0.1.0 → 0.2.0

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: 41a552daa168903056def19dfee44dbb70ced2b1
4
- data.tar.gz: f62493d655a4e333afd44a6b83558a416bc83eb3
3
+ metadata.gz: d16f65bf68908d725fd1f187ab7fb776fcc5eb4c
4
+ data.tar.gz: e7d53f74bd6d52e3977a1c821c512a645b9f578c
5
5
  SHA512:
6
- metadata.gz: 7a93ea6b63fd8193ec17d85870b8bed1d3fa90dc6b32b2ba237d86b47e5de477900c467b769a5bd496898406c6f2c53a8daea9d649b4ff891e0929db016394ac
7
- data.tar.gz: a15320ac7087fbecd4f3390e6cec06925d8dc582e3269a174f5b9dd58a4b9b3581d1c4c93c5cec5ec267952b3ea156665f63d500943e9be7f8254d539bebca63
6
+ metadata.gz: e65f8a805aa3da20be73c49af133aa87e0b046de356972a5f6be7046ad0b50f7a740c2a1a76dee2e788f5777eb559781224bec5c76b756768ea2aba95a5ac0a5
7
+ data.tar.gz: 7066b49a9d78ed73f85b73f5eb791050f8a6e70a28f9c3ecf2517be06927316310788d6ba4e80dfc0f3d8355a4818763f97e850e43a70173f48492898d04e43e
@@ -29,6 +29,24 @@ module ActiveSupport
29
29
  fail ::NotImplementedError, "The default implementation uses MULTI which isn't supported. This can be changed to use MSET and work."
30
30
  end
31
31
 
32
+ def increment(key, amount = 1, options = {})
33
+ options = merged_options(options)
34
+ ttl = _expires_in(options)
35
+ normalized_key = normalize_key(key, options)
36
+ instrument(:increment, key, :amount => amount) do
37
+ with do |c|
38
+ if ttl
39
+ c.pipelined do
40
+ c.incrby normalized_key, amount
41
+ c.expire normalized_key, ttl
42
+ end
43
+ else
44
+ c.incrby normalized_key, amount
45
+ end
46
+ end
47
+ end
48
+ end
49
+
32
50
  def read_entry(key, options)
33
51
  super
34
52
  rescue Redis::CommandError => error
@@ -44,6 +62,15 @@ module ActiveSupport
44
62
  raise if raise_errors?
45
63
  false
46
64
  end
65
+
66
+ private
67
+
68
+ def _expires_in(options)
69
+ if options
70
+ # Rack::Session Merb Rails/Sinatra
71
+ options[:expire_after] || options[:expires_in] || options[:expire_in]
72
+ end
73
+ end
47
74
  end
48
75
  end
49
76
  end
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "redis-cluster-activesupport"
6
- spec.version = "0.1.0"
6
+ spec.version = "0.2.0"
7
7
  spec.authors = ["Garrett Thornburg"]
8
8
  spec.email = ["film42@gmail.com"]
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-cluster-activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garrett Thornburg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-18 00:00:00.000000000 Z
11
+ date: 2018-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-activesupport
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.5.2
122
+ rubygems_version: 2.6.13
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Extension to redis-activesupport for working with redis cluster