redis-activesupport 5.2.0.pre → 5.2.0

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
- SHA1:
3
- metadata.gz: 9e2dae1b761efefc450f3d0058ac0e4079b7e3cc
4
- data.tar.gz: 066cc4f56fa42e97f9b0d83c04cdc5bb70062dd3
2
+ SHA256:
3
+ metadata.gz: c467729c3fee8d572a088a25cae9e2c176b22e72059269af4861a91c306c92c1
4
+ data.tar.gz: 8cfcf74186f0d12526c92688f77e6ec3ec752d17fc8e09104ce74bb3c98459b9
5
5
  SHA512:
6
- metadata.gz: 94636bbc45b68dfa930864d90d090d9bef4e7bd2bb59e114f5efe06bd3f3f18cfdf474e34fe9e7f4bf9b15ab5b51c42aad4a3ad12b9a374fe6311e0c78c661da
7
- data.tar.gz: c1ebf00acb907f9d5047d8cab835c0d76e78e91a01355e0fe25f2e754b294d83118398db3c4b690b5c3194b25875182cf1e4b2c2ef5e0c27a5f49744682f6f4e
6
+ metadata.gz: 3d2a2c778b147fee2b9e1951cfddeec3bf761187387e51b538c70599de80c9433d27c9ae5865e6c469eec9fc82e18b47d251d594bbe05d186d63e7c53e141306
7
+ data.tar.gz: 8613a936dca3aa2acc54579140989b3a32e36023c6e0bb1c6bc717545febdce0e9f297178bde59d124790c2ab74ebd6b3926b73774fbc5532269e75d6d88510b
@@ -1,39 +1,47 @@
1
1
  language: ruby
2
- script: 'bundle exec rake'
2
+ script: bundle exec rake
3
3
  rvm:
4
- - 2.0
5
- - 2.1
6
- - 2.2
7
- - 2.3
8
- - 2.4
9
- - ruby-head
10
- - jruby-head
4
+ - 2.0
5
+ - 2.1
6
+ - 2.3
7
+ - 2.4
8
+ - 2.5
9
+ - 2.6
10
+ - ruby-head
11
+ - jruby-head
11
12
  services:
12
- - redis-server
13
+ - redis-server
13
14
  matrix:
14
15
  allow_failures:
15
- - rvm: jruby-head
16
- - rvm: ruby-head
16
+ - rvm: jruby-head
17
+ - rvm: ruby-head
17
18
  exclude:
18
- - rvm: 2.0
19
- gemfile: gemfiles/activesupport_50.gemfile
20
- - rvm: 2.1
21
- gemfile: gemfiles/activesupport_50.gemfile
22
- - rvm: 2.0
23
- gemfile: gemfiles/activesupport_51.gemfile
24
- - rvm: 2.1
25
- gemfile: gemfiles/activesupport_51.gemfile
26
- - rvm: 2.0
27
- gemfile: gemfiles/activesupport_52.gemfile
28
- - rvm: 2.1
29
- gemfile: gemfiles/activesupport_52.gemfile
19
+ - rvm: 2.0
20
+ gemfile: gemfiles/activesupport_50.gemfile
21
+ - rvm: 2.1
22
+ gemfile: gemfiles/activesupport_50.gemfile
23
+ - rvm: 2.0
24
+ gemfile: gemfiles/activesupport_51.gemfile
25
+ - rvm: 2.1
26
+ gemfile: gemfiles/activesupport_51.gemfile
27
+ - rvm: 2.0
28
+ gemfile: gemfiles/activesupport_52.gemfile
29
+ - rvm: 2.1
30
+ gemfile: gemfiles/activesupport_52.gemfile
30
31
  notifications:
31
32
  webhooks: https://www.travisbuddy.com/
32
33
  on_success: never
33
- # Put this in your .travis.yml
34
34
  gemfile:
35
- - gemfiles/activesupport_3.gemfile
36
- - gemfiles/activesupport_4.gemfile
37
- - gemfiles/activesupport_50.gemfile
38
- - gemfiles/activesupport_51.gemfile
39
- - gemfiles/activesupport_52.gemfile
35
+ - gemfiles/activesupport_3.gemfile
36
+ - gemfiles/activesupport_4.gemfile
37
+ - gemfiles/activesupport_50.gemfile
38
+ - gemfiles/activesupport_51.gemfile
39
+ - gemfiles/activesupport_52.gemfile
40
+ deploy:
41
+ provider: rubygems
42
+ api_key:
43
+ secure: VHWLUgCtqlKjeS5uGOxS4tnEUSPiapyvBvgSpr+FUeQnjAE9jgJvz+rAmiNy/pp8fAhjH5FdyIUXuh2rE2sWcBYrOa1rCvrc7eBHdnpZ4U7ULJwQKhC/4dOE33ClaZX2pex4pv12I2218ZH5TsqdmQ0Ci0ccfNZJv0vs+IFP+kQ=
44
+ gem: redis-activesupport
45
+ on:
46
+ tags: true
47
+ repo: redis-store/redis-activesupport
@@ -0,0 +1 @@
1
+ * @tubbo
@@ -30,25 +30,25 @@ module ActiveSupport
30
30
  # RedisStore.new client: Redis.new(url: "redis://127.0.0.1:6380/1")
31
31
  # # => host: localhost, port: 6379, db: 0
32
32
  #
33
- # RedisStore.new "example.com"
33
+ # RedisStore.new "redis://example.com"
34
34
  # # => host: example.com, port: 6379, db: 0
35
35
  #
36
- # RedisStore.new "example.com:23682"
36
+ # RedisStore.new "redis://example.com:23682"
37
37
  # # => host: example.com, port: 23682, db: 0
38
38
  #
39
- # RedisStore.new "example.com:23682/1"
39
+ # RedisStore.new "redis://example.com:23682/1"
40
40
  # # => host: example.com, port: 23682, db: 1
41
41
  #
42
- # RedisStore.new "example.com:23682/1/theplaylist"
42
+ # RedisStore.new "redis://example.com:23682/1/theplaylist"
43
43
  # # => host: example.com, port: 23682, db: 1, namespace: theplaylist
44
44
  #
45
- # RedisStore.new "localhost:6379/0", "localhost:6380/0"
45
+ # RedisStore.new "redis://localhost:6379/0", "redis://localhost:6380/0"
46
46
  # # => instantiate a cluster
47
47
  #
48
- # RedisStore.new "localhost:6379/0", "localhost:6380/0", pool_size: 5, pool_timeout: 10
48
+ # RedisStore.new "redis://localhost:6379/0", "redis://localhost:6380/0", pool_size: 5, pool_timeout: 10
49
49
  # # => use a ConnectionPool
50
50
  #
51
- # RedisStore.new "localhost:6379/0", "localhost:6380/0",
51
+ # RedisStore.new "redis://localhost:6379/0", "redis://localhost:6380/0",
52
52
  # pool: ::ConnectionPool.new(size: 1, timeout: 1) { ::Redis::Store::Factory.create("localhost:6379/0") })
53
53
  # # => supply an existing connection pool (e.g. for use with redis-sentinel or redis-failover)
54
54
  def initialize(*addresses)
@@ -187,11 +187,17 @@ module ActiveSupport
187
187
  #
188
188
  # cache.increment "rabbit"
189
189
  # cache.read "rabbit", :raw => true # => "1"
190
- def increment(key, amount = 1, options = {})
191
- options = merged_options(options)
192
- instrument(:increment, key, :amount => amount) do
193
- failsafe(:increment) do
194
- with{|c| c.incrby normalize_key(key, options), amount}
190
+ def increment(name, amount = 1, options = {})
191
+ instrument :increment, name, amount: amount do
192
+ failsafe :increment do
193
+ options = merged_options(options)
194
+ key = normalize_key(name, options)
195
+
196
+ with do |c|
197
+ c.incrby(key, amount).tap do
198
+ write_key_expiry(c, key, options)
199
+ end
200
+ end
195
201
  end
196
202
  end
197
203
  end
@@ -217,11 +223,17 @@ module ActiveSupport
217
223
  #
218
224
  # cache.decrement "rabbit"
219
225
  # cache.read "rabbit", :raw => true # => "-1"
220
- def decrement(key, amount = 1, options = {})
221
- options = merged_options(options)
222
- instrument(:decrement, key, :amount => amount) do
223
- failsafe(:decrement) do
224
- with{|c| c.decrby normalize_key(key, options), amount}
226
+ def decrement(name, amount = 1, options = {})
227
+ instrument :decrement, name, amount: amount do
228
+ failsafe :decrement do
229
+ options = merged_options(options)
230
+ key = normalize_key(name, options)
231
+
232
+ with do |c|
233
+ c.decrby(key, amount).tap do
234
+ write_key_expiry(c, key, options)
235
+ end
236
+ end
225
237
  end
226
238
  end
227
239
  end
@@ -279,6 +291,12 @@ module ActiveSupport
279
291
  end
280
292
  end
281
293
 
294
+ def write_key_expiry(client, key, options)
295
+ if options[:expires_in] && client.ttl(key) < 0
296
+ client.expire key, options[:expires_in].to_i
297
+ end
298
+ end
299
+
282
300
  ##
283
301
  # Implement the ActiveSupport::Cache#delete_entry
284
302
  #
@@ -1,5 +1,5 @@
1
1
  class Redis
2
2
  module ActiveSupport
3
- VERSION = '5.2.0.pre'
3
+ VERSION = '5.2.0'
4
4
  end
5
5
  end
@@ -13,21 +13,20 @@ Gem::Specification.new do |s|
13
13
  s.description = %q{Redis store for ActiveSupport}
14
14
  s.license = 'MIT'
15
15
 
16
- s.rubyforge_project = 'redis-activesupport'
17
-
18
16
  s.files = `git ls-files`.split("\n")
19
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
19
  s.require_paths = ['lib']
22
20
 
23
21
  s.add_runtime_dependency "redis-store", '>= 1.3', '< 2'
24
- s.add_runtime_dependency 'activesupport', '>= 3', '< 6'
22
+ s.add_runtime_dependency 'activesupport', '>= 3', '< 7'
25
23
 
26
24
  s.add_development_dependency 'rake', '~> 10'
27
- s.add_development_dependency 'bundler', '~> 1.3'
25
+ s.add_development_dependency 'bundler'
28
26
  s.add_development_dependency 'mocha', '~> 0.14.0'
29
27
  s.add_development_dependency 'minitest', '>= 4.2', '< 6'
30
28
  s.add_development_dependency 'connection_pool', '~> 2.2.0'
31
29
  s.add_development_dependency 'redis-store-testing'
32
30
  s.add_development_dependency 'appraisal', '~> 2.0'
31
+ s.add_development_dependency 'pry-byebug', '~> 3'
33
32
  end
@@ -335,6 +335,24 @@ describe ActiveSupport::Cache::RedisStore do
335
335
  end
336
336
  end
337
337
 
338
+ it "increments a key with expiration time" do
339
+ with_store_management do |store|
340
+ store.increment "counter", 1, :expires_in => 1.second
341
+ store.read("counter", :raw => true).to_i.must_equal(1)
342
+ sleep 2
343
+ store.read("counter", :raw => true).must_be_nil
344
+ end
345
+ end
346
+
347
+ it "decrements a key with expiration time" do
348
+ with_store_management do |store|
349
+ store.decrement "counter", 1, :expires_in => 1.second
350
+ store.read("counter", :raw => true).to_i.must_equal(-1)
351
+ sleep 2
352
+ store.read("counter", :raw => true).must_be_nil
353
+ end
354
+ end
355
+
338
356
  it "clears the store" do
339
357
  with_store_management do |store|
340
358
  store.clear
@@ -4,4 +4,4 @@ require 'mocha/setup'
4
4
  require 'active_support'
5
5
  require 'active_support/cache/redis_store'
6
6
 
7
- puts "Testing against ActiveSupport v.#{ActiveSupport::VERSION::STRING}"
7
+ puts "Testing against ActiveSupport v#{ActiveSupport::VERSION::STRING}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0.pre
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-08-13 00:00:00.000000000 Z
12
+ date: 2019-08-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis-store
@@ -40,7 +40,7 @@ dependencies:
40
40
  version: '3'
41
41
  - - "<"
42
42
  - !ruby/object:Gem::Version
43
- version: '6'
43
+ version: '7'
44
44
  type: :runtime
45
45
  prerelease: false
46
46
  version_requirements: !ruby/object:Gem::Requirement
@@ -50,7 +50,7 @@ dependencies:
50
50
  version: '3'
51
51
  - - "<"
52
52
  - !ruby/object:Gem::Version
53
- version: '6'
53
+ version: '7'
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: rake
56
56
  requirement: !ruby/object:Gem::Requirement
@@ -69,16 +69,16 @@ dependencies:
69
69
  name: bundler
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: '1.3'
74
+ version: '0'
75
75
  type: :development
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: '1.3'
81
+ version: '0'
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: mocha
84
84
  requirement: !ruby/object:Gem::Requirement
@@ -155,6 +155,20 @@ dependencies:
155
155
  - - "~>"
156
156
  - !ruby/object:Gem::Version
157
157
  version: '2.0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: pry-byebug
160
+ requirement: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - "~>"
163
+ - !ruby/object:Gem::Version
164
+ version: '3'
165
+ type: :development
166
+ prerelease: false
167
+ version_requirements: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - "~>"
170
+ - !ruby/object:Gem::Version
171
+ version: '3'
158
172
  description: Redis store for ActiveSupport
159
173
  email:
160
174
  - me@lucaguidi.com
@@ -166,6 +180,7 @@ files:
166
180
  - ".gitignore"
167
181
  - ".travis.yml"
168
182
  - Appraisals
183
+ - CODEOWNERS
169
184
  - Gemfile
170
185
  - MIT-LICENSE
171
186
  - README.md
@@ -196,12 +211,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
196
211
  version: '0'
197
212
  required_rubygems_version: !ruby/object:Gem::Requirement
198
213
  requirements:
199
- - - ">"
214
+ - - ">="
200
215
  - !ruby/object:Gem::Version
201
- version: 1.3.1
216
+ version: '0'
202
217
  requirements: []
203
- rubyforge_project: redis-activesupport
204
- rubygems_version: 2.6.14
218
+ rubygems_version: 3.0.6
205
219
  signing_key:
206
220
  specification_version: 4
207
221
  summary: Redis store for ActiveSupport