redis-cluster-activesupport 0.2.0 → 1.0.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
- SHA1:
3
- metadata.gz: d16f65bf68908d725fd1f187ab7fb776fcc5eb4c
4
- data.tar.gz: e7d53f74bd6d52e3977a1c821c512a645b9f578c
2
+ SHA256:
3
+ metadata.gz: 0c5866199404c1afb551f773eee43d2f6590732581a0f804813d9ef8ddca0ae5
4
+ data.tar.gz: 78e6603647d4e490b783354357ced8ce5dfcd42d4be7e3671e5bd2eecac09017
5
5
  SHA512:
6
- metadata.gz: e65f8a805aa3da20be73c49af133aa87e0b046de356972a5f6be7046ad0b50f7a740c2a1a76dee2e788f5777eb559781224bec5c76b756768ea2aba95a5ac0a5
7
- data.tar.gz: 7066b49a9d78ed73f85b73f5eb791050f8a6e70a28f9c3ecf2517be06927316310788d6ba4e80dfc0f3d8355a4818763f97e850e43a70173f48492898d04e43e
6
+ metadata.gz: cbf4f992e5a52c00c512ace7ef29e7a39adbb87cb8df032c9497f1d50339ec399547a98b64e90ebfc9acfd0c8d7de8e2a0bb9ac31235b255eebe521dd3e5541c
7
+ data.tar.gz: ed4af5ebf896fac0452462c47f3aa37db61acdd5583ae82f4a6e58139fbf72e69c7d463a310ede8d95dbfc1d0af752bbb322181d753ce79e60bbe1de1f3f9660
@@ -0,0 +1,37 @@
1
+ # This workflow uses actions that are not certified by GitHub. They are
2
+ # provided by a third-party and are governed by separate terms of service,
3
+ # privacy policy, and support documentation.
4
+ #
5
+ # This workflow will install a prebuilt Ruby version, install dependencies, and
6
+ # run tests and linters.
7
+ name: "redis-cluster-activesupport"
8
+ on:
9
+ push:
10
+ branches: [ master ]
11
+ pull_request:
12
+ branches: [ master ]
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ ruby-version: [ '3.2', '3.1', '3.0', '2.7', '2.6', 'jruby-9.3', 'jruby-9.4' ]
19
+ gemfile: [ 'rails60', 'rails61' ]
20
+ env:
21
+ RAILS_ENV: test
22
+ steps:
23
+ - name: Checkout code
24
+ uses: actions/checkout@v3
25
+ # Add or replace dependency steps here
26
+ - name: Install Ruby and gems
27
+ uses: ruby/setup-ruby@v1
28
+ with:
29
+ bundler-cache: true
30
+ ruby-version: ${{ matrix.ruby-version }}
31
+ env:
32
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
33
+ # Add or replace test runners here
34
+ - name: Run tests
35
+ run: bundle exec rspec
36
+ env:
37
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
data/.travis.yml CHANGED
@@ -1,7 +1,15 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4
4
- - 2.3
3
+ - jruby-9.4
4
+ - jruby-9.3
5
+ - 3.2
6
+ - 3.1
7
+ - 3.0
8
+ - 2.7
9
+ - 2.6
10
+ gemfile:
11
+ - gemfiles/rails60.gemfile
12
+ - gemfiles/rails61.gemfile
5
13
  sudo: false
6
14
  cache: bundler
7
15
  notifications:
data/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # Redis cluster stores for ActiveSupport [![Build Status](https://travis-ci.org/film42/redis-cluster-activesupport.svg?branch=master)](https://travis-ci.org/film42/redis-cluster-activesupport)
2
2
 
3
- This gem is an extension to [redis-activesupport](https://github.com/redis-store/redis-activesupport) that adds support
3
+ This gem was an extension to [redis-activesupport](https://github.com/redis-store/redis-activesupport) that adds support
4
4
  for a few features required to use `redis-store` with redis cluster. Right now there isn't an official redis cluster
5
- client in ruby, so it's become common to use a redis cluster proxy like [corvus](https://github.com/eleme/corvus). When
5
+ client in ruby, so it's become common to use a redis cluster proxy like [corvus](https://github.com/eleme/corvus) or Envoy. When
6
6
  switching there are a few things you can't do with redis cluster that you can do with a single redis server. Most of
7
7
  them revolve around issuing commands with multiple keys. In redis cluster, your keys are partitioned and live on
8
- different physical servers, operations like `KEYS` are not possible. Corvus will break apart `MSET` and `MGET` into
9
- individual `GET` and `SET` commands automatically, but in general, it's not a good idea to use them.
8
+ different physical servers, operations like `KEYS` are not possible.
9
+
10
+ This is now leveraging Rails 6's built-in redis cache store with troubled commands removed.
10
11
 
11
12
  ## Usage
12
13
 
@@ -21,30 +22,6 @@ module MyProject
21
22
  end
22
23
  ```
23
24
 
24
- Additionally, there's a new configuration option: `:ignored_command_errors`. This is useful if you're using a redis
25
- cluster proxy like corvus who will raise a `Redis::CommandError` with a message indicating the cluster is offline or
26
- experiencing a partial outage. This extension allows you to whitelist certain `ignored_command_errors` that would
27
- normally be raised by `redis-activesupport`. By default this gem whitelists the following errors:
28
-
29
- ```ruby
30
- DEFAULT_IGNORED_COMMAND_ERRORS = ["ERR Proxy error"]
31
- ```
32
-
33
- If you need additional errors added to the whitelist, you can do this through your own configuration or open a pull
34
- request to add it to the default whitelist. NOTE: this list is turned into a `Set` to keep lookups fast, so feel free to
35
- make this list as big as you need. Example:
36
-
37
- ```ruby
38
- module MyProject
39
- class Application < Rails::Application
40
- config.cache_store = :redis_cluster_store, {:ignored_command_errors => ["Uh oh", "Please, stop", "Fire emoji"]}
41
- end
42
- end
43
- ```
44
-
45
- With this change, your cache store will now silently fail once again so a redis cluster won't knock your rails apps
46
- offline.
47
-
48
25
 
49
26
  ## Installation
50
27
 
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activesupport", "~> 6.0.0"
4
+ gemspec path: "../"
@@ -0,0 +1,71 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ redis-cluster-activesupport (0.3.0)
5
+ activesupport (~> 6.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (6.0.6.1)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 0.7, < 2)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ zeitwerk (~> 2.2, >= 2.2.2)
16
+ coderay (1.1.3)
17
+ concurrent-ruby (1.2.0)
18
+ diff-lcs (1.5.0)
19
+ fakeredis (0.8.0)
20
+ redis (~> 4.1)
21
+ ffi (1.15.5-java)
22
+ i18n (1.12.0)
23
+ concurrent-ruby (~> 1.0)
24
+ method_source (1.0.0)
25
+ minitest (5.17.0)
26
+ pry (0.14.2)
27
+ coderay (~> 1.1)
28
+ method_source (~> 1.0)
29
+ pry (0.14.2-java)
30
+ coderay (~> 1.1)
31
+ method_source (~> 1.0)
32
+ spoon (~> 0.0)
33
+ rake (10.5.0)
34
+ redis (4.8.0)
35
+ rspec (3.12.0)
36
+ rspec-core (~> 3.12.0)
37
+ rspec-expectations (~> 3.12.0)
38
+ rspec-mocks (~> 3.12.0)
39
+ rspec-core (3.12.1)
40
+ rspec-support (~> 3.12.0)
41
+ rspec-expectations (3.12.2)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.12.0)
44
+ rspec-mocks (3.12.3)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.12.0)
47
+ rspec-support (3.12.0)
48
+ spoon (0.0.6)
49
+ ffi
50
+ thread_safe (0.3.6)
51
+ thread_safe (0.3.6-java)
52
+ tzinfo (1.2.11)
53
+ thread_safe (~> 0.1)
54
+ zeitwerk (2.6.6)
55
+
56
+ PLATFORMS
57
+ universal-java-1.8
58
+ universal-java-11
59
+ x86_64-linux
60
+
61
+ DEPENDENCIES
62
+ activesupport (~> 6.0.0)
63
+ bundler
64
+ fakeredis
65
+ pry
66
+ rake (~> 10.0)
67
+ redis-cluster-activesupport!
68
+ rspec (~> 3.0)
69
+
70
+ BUNDLED WITH
71
+ 2.4.6
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activesupport", "~> 6.1.0"
4
+ gemspec path: "../"
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ redis-cluster-activesupport (0.3.0)
5
+ activesupport (~> 6.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (6.1.7.2)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
15
+ zeitwerk (~> 2.3)
16
+ coderay (1.1.3)
17
+ concurrent-ruby (1.2.0)
18
+ diff-lcs (1.5.0)
19
+ fakeredis (0.8.0)
20
+ redis (~> 4.1)
21
+ ffi (1.15.5-java)
22
+ i18n (1.12.0)
23
+ concurrent-ruby (~> 1.0)
24
+ method_source (1.0.0)
25
+ minitest (5.17.0)
26
+ pry (0.14.2)
27
+ coderay (~> 1.1)
28
+ method_source (~> 1.0)
29
+ pry (0.14.2-java)
30
+ coderay (~> 1.1)
31
+ method_source (~> 1.0)
32
+ spoon (~> 0.0)
33
+ rake (10.5.0)
34
+ redis (4.8.0)
35
+ rspec (3.12.0)
36
+ rspec-core (~> 3.12.0)
37
+ rspec-expectations (~> 3.12.0)
38
+ rspec-mocks (~> 3.12.0)
39
+ rspec-core (3.12.1)
40
+ rspec-support (~> 3.12.0)
41
+ rspec-expectations (3.12.2)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.12.0)
44
+ rspec-mocks (3.12.3)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.12.0)
47
+ rspec-support (3.12.0)
48
+ spoon (0.0.6)
49
+ ffi
50
+ tzinfo (2.0.6)
51
+ concurrent-ruby (~> 1.0)
52
+ zeitwerk (2.6.6)
53
+
54
+ PLATFORMS
55
+ universal-java-1.8
56
+ universal-java-11
57
+ x86_64-linux
58
+
59
+ DEPENDENCIES
60
+ activesupport (~> 6.1.0)
61
+ bundler
62
+ fakeredis
63
+ pry
64
+ rake (~> 10.0)
65
+ redis-cluster-activesupport!
66
+ rspec (~> 3.0)
67
+
68
+ BUNDLED WITH
69
+ 2.4.6
@@ -1,26 +1,8 @@
1
- require "redis-activesupport"
2
- require "set"
1
+ require "active_support"
3
2
 
4
3
  module ActiveSupport
5
4
  module Cache
6
- class RedisClusterStore < RedisStore
7
- attr_reader :ignored_command_errors
8
-
9
- DEFAULT_IGNORED_COMMAND_ERRORS = ["ERR Proxy error"].freeze
10
-
11
- def initialize(*)
12
- super
13
- @ignored_command_errors = ::Set.new(@options.fetch(:ignored_command_errors, DEFAULT_IGNORED_COMMAND_ERRORS))
14
- end
15
-
16
- def delete_entry(key, options)
17
- super
18
- rescue Redis::CommandError => error
19
- raise unless ignored_command_errors.include?(error.message)
20
- raise if raise_errors?
21
- false
22
- end
23
-
5
+ class RedisClusterStore < RedisCacheStore
24
6
  def delete_matched(matcher, options = nil)
25
7
  fail ::NotImplementedError, "Deleting keys with a matcher is not supported with redis cluster"
26
8
  end
@@ -36,10 +18,11 @@ module ActiveSupport
36
18
  instrument(:increment, key, :amount => amount) do
37
19
  with do |c|
38
20
  if ttl
39
- c.pipelined do
21
+ new_value, _ = c.pipelined do
40
22
  c.incrby normalized_key, amount
41
23
  c.expire normalized_key, ttl
42
24
  end
25
+ new_value
43
26
  else
44
27
  c.incrby normalized_key, amount
45
28
  end
@@ -47,22 +30,6 @@ module ActiveSupport
47
30
  end
48
31
  end
49
32
 
50
- def read_entry(key, options)
51
- super
52
- rescue Redis::CommandError => error
53
- raise unless ignored_command_errors.include?(error.message)
54
- raise if raise_errors?
55
- nil
56
- end
57
-
58
- def write_entry(key, entry, options)
59
- super
60
- rescue Redis::CommandError => error
61
- raise unless ignored_command_errors.include?(error.message)
62
- raise if raise_errors?
63
- false
64
- end
65
-
66
33
  private
67
34
 
68
35
  def _expires_in(options)
@@ -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.2.0"
6
+ spec.version = "1.0.0"
7
7
  spec.authors = ["Garrett Thornburg"]
8
8
  spec.email = ["film42@gmail.com"]
9
9
 
@@ -19,9 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency "redis-activesupport"
22
+ spec.add_dependency "activesupport", "~> 6.0"
23
+ spec.add_development_dependency "bundler"
24
+ spec.add_development_dependency "fakeredis"
23
25
  spec.add_development_dependency "pry"
24
- spec.add_development_dependency "bundler", "~> 1.15"
25
26
  spec.add_development_dependency "rake", "~> 10.0"
26
27
  spec.add_development_dependency "rspec", "~> 3.0"
27
28
  end
metadata CHANGED
@@ -1,23 +1,37 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-cluster-activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.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: 2018-04-17 00:00:00.000000000 Z
11
+ date: 2023-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: redis-activesupport
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '6.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '6.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - ">="
18
32
  - !ruby/object:Gem::Version
19
33
  version: '0'
20
- type: :runtime
34
+ type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
@@ -25,7 +39,7 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
- name: pry
42
+ name: fakeredis
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
@@ -39,19 +53,19 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: bundler
56
+ name: pry
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: '1.15'
61
+ version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: '1.15'
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -87,6 +101,7 @@ executables: []
87
101
  extensions: []
88
102
  extra_rdoc_files: []
89
103
  files:
104
+ - ".github/workflows/ci.yml"
90
105
  - ".gitignore"
91
106
  - ".rspec"
92
107
  - ".travis.yml"
@@ -96,6 +111,10 @@ files:
96
111
  - Rakefile
97
112
  - bin/console
98
113
  - bin/setup
114
+ - gemfiles/rails60.gemfile
115
+ - gemfiles/rails60.gemfile.lock
116
+ - gemfiles/rails61.gemfile
117
+ - gemfiles/rails61.gemfile.lock
99
118
  - lib/active_support/cache/redis_cluster_store.rb
100
119
  - lib/redis/cluster/activesupport.rb
101
120
  - redis-cluster-activesupport.gemspec
@@ -118,8 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
137
  - !ruby/object:Gem::Version
119
138
  version: '0'
120
139
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.6.13
140
+ rubygems_version: 3.1.6
123
141
  signing_key:
124
142
  specification_version: 4
125
143
  summary: Extension to redis-activesupport for working with redis cluster