redis-namespace 1.8.1 → 1.8.2

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
2
  SHA256:
3
- metadata.gz: 781a6361b78e31842c9fe934161b83e1acf9d1c1ef50cd015694b78582b461ac
4
- data.tar.gz: a0856e98fb69b1063c460ef1479dd57a4659741612b398d3fac2d4bb3727e1b0
3
+ metadata.gz: 0541ad1ce3251b5dc3c035e47aa0690d334d32b9c5b29e335604570cb5847dac
4
+ data.tar.gz: '0877ceadbd1afa44a38fd1b7bb7af4b0e9e87a3426f688c891c847853588f65a'
5
5
  SHA512:
6
- metadata.gz: caf163b05d1f4c5f08a29d4d1f977d666f1a627b582af762f50d883df64f0f2139fe132918edbc6c59d9259f386f7ed7a094da3493579072f25d9c957da7e7eb
7
- data.tar.gz: 951f20c3aaedd77400f34b161fb642d39ff0a4e8a619506441288f6671043a3bfd3e1f18e13a62fc8e014f79d989246fcb51b351f4d3f1b6f3a2a6ce8f17bd41
6
+ metadata.gz: 9c8cd0be52f98f4fe16b551ac261faba1db4da269a07ac9c85e4a8a4b20347c0a4646036bc5fb64cab3d5863d88b308f15ea96996fd19bfad8bd85980ccf5081
7
+ data.tar.gz: 1d6e8e911c9bf887ff00cead444978ecfcccd6f2b04c56549fd28542864e7971ca9f4e5510d2e7473efb91bac50be8ac7d7cd9555fea5ca0da63d8b374d3e793
data/README.md CHANGED
@@ -79,7 +79,7 @@ namespaced.redis.flushall()
79
79
 
80
80
  As mentioned above, 2.0 will remove blind passthrough and the administrative command passthrough.
81
81
  By default in 1.5+, deprecation warnings are present and enabled;
82
- they can be silenced by initializing `Redis::Namespace` with `warnings: false` or by setting the `REDIS_NAMESPACE_QUIET` environment variable.
82
+ they can be silenced by initializing `Redis::Namespace` with `warning: false` or by setting the `REDIS_NAMESPACE_QUIET` environment variable.
83
83
 
84
84
  Early opt-in
85
85
  ------------
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Redis
4
4
  class Namespace
5
- VERSION = '1.8.1'
5
+ VERSION = '1.8.2'
6
6
  end
7
7
  end
@@ -492,6 +492,12 @@ class Redis
492
492
  end
493
493
  ruby2_keywords(:call_with_namespace) if respond_to?(:ruby2_keywords, true)
494
494
 
495
+ protected
496
+
497
+ def redis=(redis)
498
+ @redis = redis
499
+ end
500
+
495
501
  private
496
502
 
497
503
  if Hash.respond_to?(:ruby2_keywords_hash)
@@ -520,12 +526,13 @@ class Redis
520
526
  end
521
527
 
522
528
  def namespaced_block(command, &block)
523
- redis.send(command) do |r|
524
- begin
525
- original, @redis = @redis, r
526
- yield self
527
- ensure
528
- @redis = original
529
+ if block.arity == 0
530
+ redis.send(command, &block)
531
+ else
532
+ redis.send(command) do |r|
533
+ copy = dup
534
+ copy.redis = r
535
+ yield copy
529
536
  end
530
537
  end
531
538
  end
data/spec/redis_spec.rb CHANGED
@@ -6,25 +6,14 @@ describe "redis" do
6
6
  @redis_version = Gem::Version.new(Redis.current.info["redis_version"])
7
7
  let(:redis_client) { @redis.respond_to?(:_client) ? @redis._client : @redis.client}
8
8
 
9
- before(:all) do
9
+ before(:each) do
10
10
  # use database 15 for testing so we dont accidentally step on your real data
11
11
  @redis = Redis.new :db => 15
12
- end
13
-
14
- before(:each) do
15
- @namespaced = Redis::Namespace.new(:ns, :redis => @redis)
16
12
  @redis.flushdb
13
+ @namespaced = Redis::Namespace.new(:ns, :redis => @redis)
17
14
  @redis.set('foo', 'bar')
18
15
  end
19
16
 
20
- after(:each) do
21
- @redis.flushdb
22
- end
23
-
24
- after(:all) do
25
- @redis.quit
26
- end
27
-
28
17
  # redis-rb 3.3.4+
29
18
  it "should inject :namespace into connection info" do
30
19
  info = @redis.connection.merge(:namespace => :ns)
@@ -398,6 +387,27 @@ describe "redis" do
398
387
  expect(result).to eq(["bar", "value"])
399
388
  end
400
389
 
390
+ it "is thread safe for multi blocks" do
391
+ mon = Monitor.new
392
+ entered = false
393
+ entered_cond = mon.new_cond
394
+
395
+ thread = Thread.new do
396
+ mon.synchronize do
397
+ entered_cond.wait_until { entered }
398
+ @namespaced.multi
399
+ end
400
+ end
401
+
402
+ @namespaced.multi do |transaction|
403
+ entered = true
404
+ mon.synchronize { entered_cond.signal }
405
+ thread.join(0.1)
406
+ transaction.get("foo")
407
+ end
408
+ thread.join
409
+ end
410
+
401
411
  it "should add namespace to strlen" do
402
412
  @namespaced.set("mykey", "123456")
403
413
  expect(@namespaced.strlen("mykey")).to eq(6)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-namespace
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2021-02-04 00:00:00.000000000 Z
14
+ date: 2022-03-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: redis
@@ -97,8 +97,8 @@ licenses:
97
97
  metadata:
98
98
  bug_tracker_uri: https://github.com/resque/redis-namespace/issues
99
99
  changelog_uri: https://github.com/resque/redis-namespace/blob/master/CHANGELOG.md
100
- documentation_uri: https://www.rubydoc.info/gems/redis-namespace/1.8.1
101
- source_code_uri: https://github.com/resque/redis-namespace/tree/v1.8.1
100
+ documentation_uri: https://www.rubydoc.info/gems/redis-namespace/1.8.2
101
+ source_code_uri: https://github.com/resque/redis-namespace/tree/v1.8.2
102
102
  post_install_message:
103
103
  rdoc_options: []
104
104
  require_paths:
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
- rubygems_version: 3.1.4
117
+ rubygems_version: 3.1.2
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: Namespaces Redis commands.