red_blocks 0.1.6 → 0.1.7

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
  SHA256:
3
- metadata.gz: 4ad5494be31aea52760f0d305781e4a96431ae3bb9e746f5837bf5682a4e84b9
4
- data.tar.gz: ef3d19d4820e606e4aaaabe748f2b666242cf20e749f7ddfa4294ee7a858c00d
3
+ metadata.gz: 55b03475a362f7e4f4de3da9a17d8ce3f8ba45a65018abb7b5400a256d951732
4
+ data.tar.gz: 1be31a031e4a2c999e64b5fd6d2395cf0b7b0b54d6e6b21026fb25dd11e68654
5
5
  SHA512:
6
- metadata.gz: 6d15881bf5e788c30a6e5783a836b8156db52cd0c9ade17aff109dc0e71739ad70238d82f8a0fec3e1d70cd14764b64709da2e145685c19645e6620485992590
7
- data.tar.gz: 52ca2f9997d7d827d63e255cb0b0c8785a36b07382a428c3cab4bdb2930a567055f40bfbf5afc126b2a0e8f823c5a3d8f272b299b99ada95ba4f3bf46f4b24f8
6
+ metadata.gz: 3b0a7f6a2cc0a1329f6d424e4a32118e4650c511b27fbb6fcad147de6d5d2582a2d1405376fdeaa123af5ddf87b3955fd7e43bba8d3fba552f05916670c4bc13
7
+ data.tar.gz: e38ad3d62403cca86668277a04a3bdbab95c2059a14e6920136d80098e58b673d6902adea81e03625af92f7d5970afe99c3b990c16ab321bbd3a4eb6041f680e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## CHANGELOG
2
2
 
3
+ ### v0.1.7 / 2023-06-21
4
+ - Make compatible to redis gem 5 series @KeiSakam https://github.com/Altech/red_blocks/pull/13
5
+
3
6
  ### v0.1.6 / 2022-09-02
4
7
  - Make ComposedSet#update! safe to Redis connection lost by @stomk https://github.com/Altech/red_blocks/pull/12
5
8
 
@@ -27,9 +27,9 @@ module RedBlocks
27
27
 
28
28
  def update!
29
29
  disabled_sets.each(&:update!)
30
- RedBlocks.client.pipelined do
31
- compose_sets!
32
- RedBlocks.client.expire(key, expiration_time)
30
+ RedBlocks.client.pipelined do |pipeline|
31
+ compose_sets!(pipeline)
32
+ pipeline.expire(key, expiration_time)
33
33
  end
34
34
  end
35
35
 
@@ -43,13 +43,13 @@ module RedBlocks
43
43
 
44
44
  private
45
45
 
46
- def compose_sets!
46
+ def compose_sets!(pipeline)
47
47
  raise NotImplementedError
48
48
  end
49
49
 
50
50
  def disabled_sets
51
- ttls = RedBlocks.client.pipelined do
52
- @sets.each { |set| RedBlocks.client.ttl(set.key) }
51
+ ttls = RedBlocks.client.pipelined do |pipeline|
52
+ @sets.each { |set| pipeline.ttl(set.key) }
53
53
  end
54
54
  @sets.zip(ttls).select do |set, ttl|
55
55
  set.disabled?(ttl)
@@ -2,13 +2,13 @@ module RedBlocks
2
2
  class IntersectionSet < ComposedSet
3
3
  private
4
4
 
5
- def compose_sets!
5
+ def compose_sets!(pipeline)
6
6
  sets = @sets.to_a
7
7
  if sets.size > 0
8
- RedBlocks.client.zinterstore(key, sets.map(&:key), weights: sets.map(&:weight), aggregate: score_func)
8
+ pipeline.zinterstore(key, sets.map(&:key), weights: sets.map(&:weight), aggregate: score_func)
9
9
  else
10
- RedBlocks.client.del(key)
11
- RedBlocks.client.zadd(key, normalize_entries([]))
10
+ pipeline.del(key)
11
+ pipeline.zadd(key, normalize_entries([]))
12
12
  end
13
13
  end
14
14
  end
@@ -3,9 +3,9 @@
3
3
  module RedBlocks::Operations
4
4
  def self.delete(set_or_pattern)
5
5
  keys = self.keys(set_or_pattern)
6
- RedBlocks.client.pipelined do
6
+ RedBlocks.client.pipelined do |pipeline|
7
7
  keys.each do |key|
8
- RedBlocks.client.del(key)
8
+ pipeline.del(key)
9
9
  end
10
10
  end
11
11
  end
@@ -6,10 +6,10 @@ module RedBlocks
6
6
  def update!(get_result = self.get)
7
7
  entries = normalize_entries(validate_entries!(get_result))
8
8
  removed_ids = self.ids(paginator: Paginator.all, update_if_disabled: false) - entries.map(&:last)
9
- RedBlocks.client.pipelined do
10
- RedBlocks.client.zrem(key, removed_ids) if removed_ids.size > 0
11
- RedBlocks.client.zadd(key, entries)
12
- RedBlocks.client.expire(key, expiration_time)
9
+ RedBlocks.client.pipelined do |pipeline|
10
+ pipeline.zrem(key, removed_ids) if removed_ids.size > 0
11
+ pipeline.zadd(key, entries)
12
+ pipeline.expire(key, expiration_time)
13
13
  end
14
14
  nil
15
15
  end
@@ -40,8 +40,8 @@ module RedBlocks
40
40
  private
41
41
 
42
42
  def disabled_sets
43
- ttls = RedBlocks.client.pipelined do
44
- sets.each { |set| RedBlocks.client.ttl(set.key) }
43
+ ttls = RedBlocks.client.pipelined do |pipeline|
44
+ sets.each { |set| pipeline.ttl(set.key) }
45
45
  end
46
46
  sets.zip(ttls).select do |set, ttl|
47
47
  set.disabled?(ttl)
@@ -2,13 +2,13 @@ module RedBlocks
2
2
  class UnionSet < ComposedSet
3
3
  private
4
4
 
5
- def compose_sets!
5
+ def compose_sets!(pipeline)
6
6
  sets = @sets.to_a
7
7
  if sets.size > 0
8
- RedBlocks.client.zunionstore(key, sets.map(&:key), weights: sets.map(&:weight), aggregate: score_func)
8
+ pipeline.zunionstore(key, sets.map(&:key), weights: sets.map(&:weight), aggregate: score_func)
9
9
  else
10
- RedBlocks.client.del(key)
11
- RedBlocks.client.zadd(key, normalize_entries([]))
10
+ pipeline.del(key)
11
+ pipeline.zadd(key, normalize_entries([]))
12
12
  end
13
13
  end
14
14
  end
@@ -1,3 +1,3 @@
1
1
  module RedBlocks
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/red_blocks.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.required_ruby_version = '>= 2.4.0'
25
25
 
26
- spec.add_dependency "redis", ">= 3.3", "< 5.0"
26
+ spec.add_dependency "redis", ">= 3.3", "< 6.0"
27
27
  spec.add_development_dependency "bundler"
28
28
  spec.add_development_dependency "rake", "~> 13.0"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red_blocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Altech
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-04 00:00:00.000000000 Z
11
+ date: 2023-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '3.3'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5.0'
22
+ version: '6.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '3.3'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5.0'
32
+ version: '6.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement