Module: Gitlab::Patch::RedisCacheStore
- Defined in:
- lib/gitlab/patch/redis_cache_store.rb
Instance Method Summary collapse
-
#delete_multi_entries(entries, **options) ⇒ Object
‘delete_multi_entries` in Rails runs a multi-key `del` command patch will run pipelined single-key `del` for Redis Cluster compatibility.
-
#initialize(*args, **kwargs) ⇒ Object
The initialize calls retrieve_pool_options method: github.com/rails/rails/blob/v7.1.5.1/activesupport/lib/active_support/cache/redis_cache_store.rb#L149 In Rails 7.1 the method changed and now it always returns something.
-
#pipeline_entries(entries, &block) ⇒ Object
‘pipeline_entries` is used by Rails for multi-key writes patch will run pipelined single-key for Redis Cluster compatibility.
-
#read_multi_entries(names, **options) ⇒ Object
We will try keep patched code explicit and matching the original signature in github.com/rails/rails/blob/v7.1.3.4/activesupport/lib/active_support/cache/redis_cache_store.rb#L324.
Instance Method Details
#delete_multi_entries(entries, **options) ⇒ Object
‘delete_multi_entries` in Rails runs a multi-key `del` command patch will run pipelined single-key `del` for Redis Cluster compatibility
34 35 36 37 38 39 40 |
# File 'lib/gitlab/patch/redis_cache_store.rb', line 34 def delete_multi_entries(entries, **) return super unless enable_rails_cache_pipeline_patch? ::Gitlab::Redis::ClusterUtil.batch_entries(entries) do |batched_names| super(batched_names) end.sum end |
#initialize(*args, **kwargs) ⇒ Object
The initialize calls retrieve_pool_options method: github.com/rails/rails/blob/v7.1.5.1/activesupport/lib/active_support/cache/redis_cache_store.rb#L149 In Rails 7.1 the method changed and now it always returns something
-
github.com/rails/rails/blob/v7.0.8.7/activesupport/lib/active_support/cache.rb#L183
-
github.com/rails/rails/blob/v7.1.5.1/activesupport/lib/active_support/cache.rb#L206
As a result, an unexpected connection pool is initialized. This path always initializes redis without a connection pool, the pool is initialized in a wrapper.
15 16 17 18 19 |
# File 'lib/gitlab/patch/redis_cache_store.rb', line 15 def initialize(*args, **kwargs) super @redis = self.class.build_redis(redis: kwargs[:redis]) end |
#pipeline_entries(entries, &block) ⇒ Object
‘pipeline_entries` is used by Rails for multi-key writes patch will run pipelined single-key for Redis Cluster compatibility
44 45 46 47 48 49 50 |
# File 'lib/gitlab/patch/redis_cache_store.rb', line 44 def pipeline_entries(entries, &block) return super unless enable_rails_cache_pipeline_patch? redis.with do |conn| ::Gitlab::Redis::ClusterUtil.batch(entries, conn, &block) end end |
#read_multi_entries(names, **options) ⇒ Object
We will try keep patched code explicit and matching the original signature in github.com/rails/rails/blob/v7.1.3.4/activesupport/lib/active_support/cache/redis_cache_store.rb#L324
23 24 25 26 27 28 29 30 |
# File 'lib/gitlab/patch/redis_cache_store.rb', line 23 def read_multi_entries(names, **) return super unless enable_rails_cache_pipeline_patch? return super unless use_patched_mget? ::Gitlab::Redis::ClusterUtil.batch_entries(names) do |batched_names| super(batched_names, **) end.reduce({}, &:merge) end |