rails-brotli-cache 0.4.3 → 0.4.5

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: 52fe3544e2a3d65acf1bba0cd17939e62d628f1dcd6482ec7110c730494527a8
4
- data.tar.gz: 9e3d9691e99051ce29ed22ccb3a7414e6a00c8037fbc877ef8892a4f4e2a2705
3
+ metadata.gz: a8625763513363be86da9d238d61e3db90c5052e9c15bb4327b0f64b799b5440
4
+ data.tar.gz: dd4ad2c3ecb8ddd622dbc202238e535dd6ac28281efba003f07d3b1f6d0add49
5
5
  SHA512:
6
- metadata.gz: d838530dedd6aea82be35754f96e9269171fe2c62f1b8654dcd0a439836d24c71b1e4d60d09931f6ed9a32d57ca6f4fe8a3e4623d04647ca8e3d46a6c020ef75
7
- data.tar.gz: '058b95a3d43191462cc98b2bc0086e37b88175aff01fbf8eb6b134eb757622a5fd999acadd39594c3b6818df36103049f57917031a26111726f6b4e722109441'
6
+ metadata.gz: 22c8e8dee56147934a6923d908af3c02b30f78194cd15128b0b4fb1f7d015eaae132d0206d73323c4d712bc33fc938175d8a881ad468df52d084cbd99f6b5e4a
7
+ data.tar.gz: 2cc953e90c76b4d7e893afe744ebeaff397372ab1b49445aaa524d5ac6ffc9ecc65210a360b0c74850f9c80a29a2807d81d35acf43b93e0b80c8806a8fec35cf
@@ -46,7 +46,7 @@ module RailsBrotliCache
46
46
  end
47
47
 
48
48
  uncompressed(
49
- @core_store.fetch(expanded_cache_key(name, options[:namespace]), options.merge(compress: false)) do
49
+ @core_store.fetch(expanded_cache_key(name), options.merge(compress: false)) do
50
50
  if block_given?
51
51
  compressed(block.call, options)
52
52
  else
@@ -62,7 +62,7 @@ module RailsBrotliCache
62
62
  payload = compressed(value, options)
63
63
 
64
64
  @core_store.write(
65
- expanded_cache_key(name, options[:namespace]),
65
+ expanded_cache_key(name),
66
66
  payload,
67
67
  options.merge(compress: false)
68
68
  )
@@ -72,7 +72,7 @@ module RailsBrotliCache
72
72
  options = (options || {}).reverse_merge(@init_options)
73
73
 
74
74
  payload = @core_store.read(
75
- expanded_cache_key(name, options[:namespace]),
75
+ expanded_cache_key(name),
76
76
  options
77
77
  )
78
78
 
@@ -83,7 +83,7 @@ module RailsBrotliCache
83
83
  options = (options || {}).reverse_merge(@init_options)
84
84
  new_hash = hash.map do |key, val|
85
85
  [
86
- expanded_cache_key(key, options[:namespace]),
86
+ expanded_cache_key(key),
87
87
  compressed(val, options)
88
88
  ]
89
89
  end
@@ -96,7 +96,7 @@ module RailsBrotliCache
96
96
 
97
97
  def read_multi(*names)
98
98
  options = names.extract_options!
99
- names = names.map { |name| expanded_cache_key(name, options[:namespace]) }
99
+ names = names.map { |name| expanded_cache_key(name) }
100
100
  options = options.reverse_merge(@init_options)
101
101
 
102
102
  core_store.read_multi(*names, options).map do |key, val|
@@ -106,7 +106,7 @@ module RailsBrotliCache
106
106
 
107
107
  def fetch_multi(*names)
108
108
  options = names.extract_options!
109
- names = names.map { |name| expanded_cache_key(name, options[:namespace]) }
109
+ names = names.map { |name| expanded_cache_key(name) }
110
110
  options = options.reverse_merge(@init_options)
111
111
 
112
112
  @core_store.fetch_multi(
@@ -117,11 +117,11 @@ module RailsBrotliCache
117
117
  end
118
118
 
119
119
  def exist?(name, options = {})
120
- @core_store.exist?(expanded_cache_key(name, options[:namespace]), options)
120
+ @core_store.exist?(expanded_cache_key(name), options)
121
121
  end
122
122
 
123
123
  def delete(name, options = {})
124
- @core_store.delete(expanded_cache_key(name, options[:namespace]), options)
124
+ @core_store.delete(expanded_cache_key(name), options)
125
125
  end
126
126
 
127
127
  def clear
@@ -129,11 +129,11 @@ module RailsBrotliCache
129
129
  end
130
130
 
131
131
  def increment(name, amount = 1, **options)
132
- @core_store.increment(expanded_cache_key(name, options[:namespace]), amount, **options)
132
+ @core_store.increment(expanded_cache_key(name), amount, **options)
133
133
  end
134
134
 
135
135
  def decrement(name, amount = 1, **options)
136
- @core_store.decrement(expanded_cache_key(name, options[:namespace]), amount, **options)
136
+ @core_store.decrement(expanded_cache_key(name), amount, **options)
137
137
  end
138
138
 
139
139
  def self.supports_cache_versioning?
@@ -174,8 +174,8 @@ module RailsBrotliCache
174
174
  Marshal.load(serialized)
175
175
  end
176
176
 
177
- def expanded_cache_key(name, namespace = nil)
178
- "#{@prefix}#{::ActiveSupport::Cache.expand_cache_key(name, namespace)}"
177
+ def expanded_cache_key(name)
178
+ "#{@prefix}#{::ActiveSupport::Cache.expand_cache_key(name)}"
179
179
  end
180
180
 
181
181
  def source_cache_key(name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsBrotliCache
4
- VERSION = "0.4.3"
4
+ VERSION = "0.4.5"
5
5
  end
@@ -21,4 +21,8 @@ Gem::Specification.new do |gem|
21
21
  gem.add_development_dependency "redis"
22
22
  gem.add_development_dependency "dalli"
23
23
  gem.add_development_dependency "byebug"
24
+
25
+ if gem.respond_to?(:metadata=)
26
+ gem.metadata = { "rubygems_mfa_required" => "true" }
27
+ end
24
28
  end
@@ -15,13 +15,18 @@ describe RailsBrotliCache do
15
15
  end
16
16
  end
17
17
 
18
+ let(:options) do
19
+ {}
20
+ end
21
+
18
22
  let(:redis_store) do
19
- ActiveSupport::Cache::RedisCacheStore.new(redis: $redis)
23
+ ActiveSupport::Cache::RedisCacheStore.new({ redis: $redis }.merge(options))
20
24
  end
21
25
 
22
26
  let(:brotli_store) do
23
27
  RailsBrotliCache::Store.new(
24
- redis_store
28
+ ActiveSupport::Cache::RedisCacheStore.new(redis: $redis),
29
+ options
25
30
  )
26
31
  end
27
32
 
@@ -49,6 +54,42 @@ describe RailsBrotliCache do
49
54
  brotli_store.fetch([:views, "controller/action", collection]) { 123 }
50
55
  expect($redis.get("views/controller/action/post/1/post/2")).to be_present
51
56
  expect($redis.get("br-views/controller/action/post/1/post/2")).to be_present
57
+ expect(brotli_store.read([:views, "controller/action", collection])).to eq 123
58
+ end
59
+
60
+ context "custom namespace string is not duplicated" do
61
+ let(:options) do
62
+ {
63
+ namespace: "myapp"
64
+ }
65
+ end
66
+
67
+ it "activemodel object keys" do
68
+ post_1 = Post.new(id: 1)
69
+ redis_store.fetch(post_1) { 123 }
70
+ brotli_store.fetch(post_1) { 123 }
71
+ expect($redis.get("myapp:post/1")).to be_present
72
+ expect($redis.get("myapp:br-post/1")).to be_present
73
+ expect(brotli_store.read(post_1)).to eq 123
74
+ end
75
+ end
76
+
77
+ context "custom namespace proc" do
78
+ @@counter = 0
79
+ let(:options) do
80
+ {
81
+ namespace: -> { "myapp" }
82
+ }
83
+ end
84
+
85
+ it "activemodel object keys" do
86
+ post_1 = Post.new(id: 1)
87
+ redis_store.fetch(post_1) { 123 }
88
+ brotli_store.fetch(post_1) { 123 }
89
+ expect($redis.get("myapp:post/1")).to be_present
90
+ expect($redis.get("myapp:br-post/1")).to be_present
91
+ expect(brotli_store.read(post_1)).to eq 123
92
+ end
52
93
  end
53
94
  end
54
95
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-brotli-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-05 00:00:00.000000000 Z
11
+ date: 2023-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -167,7 +167,8 @@ files:
167
167
  homepage: https://github.com/pawurb/rails-brotli-cache
168
168
  licenses:
169
169
  - MIT
170
- metadata: {}
170
+ metadata:
171
+ rubygems_mfa_required: 'true'
171
172
  post_install_message:
172
173
  rdoc_options: []
173
174
  require_paths: