red_blocks 0.1.5 → 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
- SHA1:
3
- metadata.gz: ba95013b534cdd836ff25acded9eec935aea998a
4
- data.tar.gz: 82cad15362d7a10e4d20d6505a45dc6087f5b9da
2
+ SHA256:
3
+ metadata.gz: 55b03475a362f7e4f4de3da9a17d8ce3f8ba45a65018abb7b5400a256d951732
4
+ data.tar.gz: 1be31a031e4a2c999e64b5fd6d2395cf0b7b0b54d6e6b21026fb25dd11e68654
5
5
  SHA512:
6
- metadata.gz: 166fdb842bc2e19bb191c49128ddc7213960a038be20bbf68a75c24e7fb0720679bd46eeb614478b6df4ac1bb2a0ded9a4fc13698298e9b52dec3d6e51a3809d
7
- data.tar.gz: 4fd75e66d99f6cf0b20ba359cb71f6de1bf0073c49c93c600a45d0350be3850e3634f1fe7b79a176fcae3970c1736cdd2ed51e3698bc8792444011e59f5f093e
6
+ metadata.gz: 3b0a7f6a2cc0a1329f6d424e4a32118e4650c511b27fbb6fcad147de6d5d2582a2d1405376fdeaa123af5ddf87b3955fd7e43bba8d3fba552f05916670c4bc13
7
+ data.tar.gz: e38ad3d62403cca86668277a04a3bdbab95c2059a14e6920136d80098e58b673d6902adea81e03625af92f7d5970afe99c3b990c16ab321bbd3a4eb6041f680e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
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
+
6
+ ### v0.1.6 / 2022-09-02
7
+ - Make ComposedSet#update! safe to Redis connection lost by @stomk https://github.com/Altech/red_blocks/pull/12
8
+
3
9
  ### v0.1.0 / 2017-12-05
4
10
 
5
11
  First release.
data/README.md CHANGED
@@ -50,8 +50,4 @@ In general, there are some advantages by using RedBlocks.
50
50
  gem 'red_blocks'
51
51
  ```
52
52
 
53
- ## Classes
54
-
55
- TODO: document
56
-
57
- [This entry](http://takenos.link/post/173086712782/redis-sorted-set-in-oop) describes the usage of RedBlocks (in japanese).
53
+ [This entry](https://qiita.com/Altech/items/db48e7906c90d542c732) and [this slide](http://speakerdeck.com/altech/object-oriented-abstraction-of-redis-sorted-set) describe the usage of RedBlocks (in japanese).
@@ -27,8 +27,10 @@ module RedBlocks
27
27
 
28
28
  def update!
29
29
  disabled_sets.each(&:update!)
30
- compose_sets!
31
- RedBlocks.client.expire(key, expiration_time)
30
+ RedBlocks.client.pipelined do |pipeline|
31
+ compose_sets!(pipeline)
32
+ pipeline.expire(key, expiration_time)
33
+ end
32
34
  end
33
35
 
34
36
  def cache_time
@@ -41,13 +43,13 @@ module RedBlocks
41
43
 
42
44
  private
43
45
 
44
- def compose_sets!
46
+ def compose_sets!(pipeline)
45
47
  raise NotImplementedError
46
48
  end
47
49
 
48
50
  def disabled_sets
49
- ttls = RedBlocks.client.pipelined do
50
- @sets.each { |set| RedBlocks.client.ttl(set.key) }
51
+ ttls = RedBlocks.client.pipelined do |pipeline|
52
+ @sets.each { |set| pipeline.ttl(set.key) }
51
53
  end
52
54
  @sets.zip(ttls).select do |set, ttl|
53
55
  set.disabled?(ttl)
@@ -2,15 +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.pipelined do
11
- RedBlocks.client.del(key)
12
- RedBlocks.client.zadd(key, normalize_entries([]))
13
- end
10
+ pipeline.del(key)
11
+ pipeline.zadd(key, normalize_entries([]))
14
12
  end
15
13
  end
16
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,15 +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.pipelined do
11
- RedBlocks.client.del(key)
12
- RedBlocks.client.zadd(key, normalize_entries([]))
13
- end
10
+ pipeline.del(key)
11
+ pipeline.zadd(key, normalize_entries([]))
14
12
  end
15
13
  end
16
14
  end
@@ -1,3 +1,3 @@
1
1
  module RedBlocks
2
- VERSION = "0.1.5"
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.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Altech
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-02 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
@@ -184,7 +184,7 @@ homepage: https://github.com/Altech/red_blocks
184
184
  licenses:
185
185
  - MIT
186
186
  metadata: {}
187
- post_install_message:
187
+ post_install_message:
188
188
  rdoc_options: []
189
189
  require_paths:
190
190
  - lib
@@ -199,9 +199,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  - !ruby/object:Gem::Version
200
200
  version: '0'
201
201
  requirements: []
202
- rubyforge_project:
203
- rubygems_version: 2.6.8
204
- signing_key:
202
+ rubygems_version: 3.2.3
203
+ signing_key:
205
204
  specification_version: 4
206
205
  summary: Object-oriented abstraction of Redis sorted set.
207
206
  test_files: []