rails-brotli-cache 0.2.3 → 0.2.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: 8f5eae03f927b9f70606cc7b4134fc7173926951da4cf05172bdd9cecb149c61
4
- data.tar.gz: c89a69ec5b5d5ddbb8efb432d253784ec30be073ca0a4d142edf347cbc4b75cb
3
+ metadata.gz: f25f2d703bace978a6a84e686d55a80aa926366d0795d032dc4bbab325b863af
4
+ data.tar.gz: 027b2040bbe634ccc19e234bbbf550262add716e3f3ecdc2a5b1c82f947847c8
5
5
  SHA512:
6
- metadata.gz: 7b8b3daea70b8c8f5cd8f445ee08155eb6356fbab042db3fd505dc26e666fe8a1011080391940d1d77e08d912ddef46d9a7908377bf6135c7784c433a37ce495
7
- data.tar.gz: 5c37c70c355770b708b7703333a4f941d5b28e51d8a6e140eb256ce5a145fa8da21a86cd72af9498f274c56c97d5b3daa9718e8a58aefe4e206d31f58a8d1471
6
+ metadata.gz: b84b6bc932bed9537116349df16b39524fc4e93b7b9e54e49e254de080e7a0513fa4a0a58722cc5a1e4a455d0c5c7d9226cf9192731a5617f4bf772eb210c5aa
7
+ data.tar.gz: bafd5345b64fb78db2815036eccbae16edd8fcbc7dc91b4acc8c1009e114be5c25e80b05e5498de1d500e3a10b138c8b086760127ba6462accaef33777fc57c8
data/README.md CHANGED
@@ -74,7 +74,7 @@ cp docker-compose.yml.sample docker-compose.yml
74
74
  docker compose up -d
75
75
  cd benchmarks
76
76
  bundle install
77
- ruby main.rb
77
+ bundle exec ruby main.rb
78
78
  ```
79
79
 
80
80
  ## Configuration
data/benchmarks/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails-brotli-cache'
4
+ gem 'redis'
5
+ gem 'dalli'
@@ -41,8 +41,9 @@ module RailsBrotliCache
41
41
 
42
42
  def write(name, value, options = nil)
43
43
  serialized = Marshal.dump(value)
44
+ options = (options || {}).reverse_merge(compress: true)
44
45
 
45
- payload = if serialized.bytesize >= COMPRESS_THRESHOLD
46
+ payload = if serialized.bytesize >= COMPRESS_THRESHOLD && !options.fetch(:compress) == false
46
47
  compressed_payload = ::Brotli.deflate(serialized, quality: COMPRESS_QUALITY)
47
48
  if compressed_payload.bytesize < serialized.bytesize
48
49
  MARK_BR_COMPRESSED + compressed_payload
@@ -56,7 +57,7 @@ module RailsBrotliCache
56
57
  @core_store.write(
57
58
  cache_key(name),
58
59
  payload,
59
- (options || {}).merge(compress: false)
60
+ options.merge(compress: false)
60
61
  )
61
62
  end
62
63
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsBrotliCache
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.5"
5
5
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
8
8
  gem.version = RailsBrotliCache::VERSION
9
9
  gem.authors = ["pawurb"]
10
10
  gem.email = ["contact@pawelurbanek.com"]
11
- gem.summary = %q{ Rails cache using Brotli algorithm offers better compression and performance. }
12
- gem.description = %q{ rails-brotli-cache allows to reduce storage needed for Rails cache by using Brotli compression which can produce outputs smaller by ~20%. }
11
+ gem.summary = %q{ Drop-in enhancement for Rails cache, offering better performance and compression with Brotli algorithm. }
12
+ gem.description = %q{ This gem reduces storage needed for Rails cache by using Brotli compression, which can produce outputs smaller by ~20% and offers better performance than Gzip. }
13
13
  gem.homepage = "https://github.com/pawurb/rails-brotli-cache"
14
14
  gem.files = `git ls-files`.split("\n")
15
15
  gem.test_files = gem.files.grep(%r{^(spec)/})
@@ -33,6 +33,12 @@ describe RailsBrotliCache do
33
33
  expect($redis.get("gz-test-key").size > $redis.get("br-test-key").size).to eq true
34
34
  end
35
35
 
36
+ it "respects { compress: false } setting and does not apply compression" do
37
+ Rails.cache.write("gz-test-key", json)
38
+ cache_store.write("test-key", json, compress: false)
39
+ expect($redis.get("gz-test-key").size < $redis.get("br-test-key").size).to eq true
40
+ end
41
+
36
42
  describe "disable_prefix" do
37
43
  context "default prefix" do
38
44
  it "appends 'br-' prefix" do
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.2.3
4
+ version: 0.2.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-05-20 00:00:00.000000000 Z
11
+ date: 2023-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -94,8 +94,8 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: " rails-brotli-cache allows to reduce storage needed for Rails cache
98
- by using Brotli compression which can produce outputs smaller by ~20%. "
97
+ description: " This gem reduces storage needed for Rails cache by using Brotli compression,
98
+ which can produce outputs smaller by ~20% and offers better performance than Gzip. "
99
99
  email:
100
100
  - contact@pawelurbanek.com
101
101
  executables: []
@@ -184,7 +184,8 @@ requirements: []
184
184
  rubygems_version: 3.1.6
185
185
  signing_key:
186
186
  specification_version: 4
187
- summary: Rails cache using Brotli algorithm offers better compression and performance.
187
+ summary: Drop-in enhancement for Rails cache, offering better performance and compression
188
+ with Brotli algorithm.
188
189
  test_files:
189
190
  - spec/dummy/Gemfile
190
191
  - spec/dummy/README.md