rails-brotli-cache 0.4.6 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +39 -0
- data/README.md +11 -2
- data/Rakefile +1 -1
- data/benchmarks/main.rb +3 -1
- data/lib/rails-brotli-cache/store.rb +4 -1
- data/lib/rails-brotli-cache/version.rb +1 -1
- data/rails-brotli-cache.gemspec +5 -2
- data/spec/dummy/config/application.rb +6 -1
- data/spec/dummy/config/environments/development.rb +1 -1
- data/spec/rails-brotli-cache/cache_keys_spec.rb +2 -3
- data/spec/rails-brotli-cache/rails_store_spec.rb +1 -1
- data/spec/rails-brotli-cache/redis_spec.rb +1 -1
- data/spec/spec_helper.rb +6 -3
- metadata +51 -9
- data/.circleci/config.yml +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38153c74bf09ef2a13760b3dea18a3a3e97790104b1af8a8d244ee104d0ad34e
|
4
|
+
data.tar.gz: ed7760dd1e7373fa7e855f57ec7082a185f68b114e43bd051d29fb4be7619020
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc9430106e033158f55f6421d42253a8aaec9b62833687538a289010e8b67b1ffc4a75ba0b71071e5925b7256d2d070b5930719ebd40d5a60f28dc6d7cd4cd19
|
7
|
+
data.tar.gz: 47483feabfac21321eb6e4e6a0df6d5ffa8646261dbeb7b728897f3026f4deff699e682a4cf525f8cca79b824082173637baf9517d8e96c3cfd91aaf9b0b3291
|
@@ -0,0 +1,39 @@
|
|
1
|
+
name: Ruby CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ main ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
services:
|
13
|
+
redis:
|
14
|
+
image: redis:alpine
|
15
|
+
ports: ["6379:6379"]
|
16
|
+
memcached:
|
17
|
+
image: memcached:alpine
|
18
|
+
ports: ["11211:11211"]
|
19
|
+
strategy:
|
20
|
+
fail-fast: false
|
21
|
+
matrix:
|
22
|
+
ruby-version: ['3.2', '3.1', '3.0', '2.7', '2.6']
|
23
|
+
steps:
|
24
|
+
- uses: actions/checkout@v3
|
25
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
26
|
+
uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
ruby-version: ${{ matrix.ruby-version }}
|
29
|
+
- name: Install dependencies
|
30
|
+
run: bundle install
|
31
|
+
- name: Run tests for Redis cache store
|
32
|
+
run: TEST_RAILS_CACHE_STORE=redis_cache_store bundle exec rspec spec
|
33
|
+
- name: Run tests for Memcache cache store
|
34
|
+
run: TEST_RAILS_CACHE_STORE=mem_cache_store bundle exec rspec spec
|
35
|
+
- name: Run tests for Brotli cache store
|
36
|
+
run: TEST_RAILS_CACHE_STORE=brotli_cache_store bundle exec rspec spec
|
37
|
+
- name: Run tests for in-memory cache store
|
38
|
+
run: bundle exec rspec spec
|
39
|
+
|
data/README.md
CHANGED
@@ -1,8 +1,17 @@
|
|
1
|
-
# Rails Brotli Cache [![Gem Version](https://img.shields.io/gem/v/rails-brotli-cache)](https://badge.fury.io/rb/rails-brotli-cache) [![
|
1
|
+
# Rails Brotli Cache [![Gem Version](https://img.shields.io/gem/v/rails-brotli-cache)](https://badge.fury.io/rb/rails-brotli-cache) [![GH Actions](https://github.com/pawurb/rails-brotli-cache/actions/workflows/ci.yml/badge.svg)](https://github.com/pawurb/rails-brotli-cache/actions)
|
2
2
|
|
3
3
|
This gem enables support for compressing Ruby on Rails cache entries using the [Brotli compression algorithm](https://github.com/google/brotli). `RailsBrotliCache::Store` offers better compression and performance compared to the default `Rails.cache` Gzip, regardless of the underlying data store. The gem also allows specifying any custom compression algorithm instead of Brotli.
|
4
4
|
|
5
|
-
|
5
|
+
You can check out [this blog post](https://pawelurbanek.com/rails-brotli-cache) describing the gem in more detail.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
`Gemfile`
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'brotli' # brotli is an optional dependency because other compressors are supported
|
13
|
+
gem 'rails-brotli-cache'
|
14
|
+
```
|
6
15
|
|
7
16
|
## Benchmarks
|
8
17
|
|
data/Rakefile
CHANGED
@@ -7,5 +7,5 @@ task default: :spec
|
|
7
7
|
|
8
8
|
desc 'Test all cache_stores'
|
9
9
|
task :test_all do
|
10
|
-
system("
|
10
|
+
system("TEST_RAILS_CACHE_STORE=redis_cache_store bundle exec rspec spec && TEST_RAILS_CACHE_STORE=brotli_cache_store bundle exec rspec spec && TEST_RAILS_CACHE_STORE=mem_cache_store bundle exec rspec spec && bundle exec rspec spec")
|
11
11
|
end
|
data/benchmarks/main.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/core_ext/hash'
|
2
3
|
require 'net/http'
|
3
4
|
require 'rails-brotli-cache'
|
5
|
+
require 'benchmark'
|
4
6
|
|
5
7
|
memory_cache = ActiveSupport::Cache::MemoryStore.new(compress: true) # memory store does not use compression by default
|
6
8
|
brotli_memory_cache = RailsBrotliCache::Store.new(memory_cache)
|
data/rails-brotli-cache.gemspec
CHANGED
@@ -15,9 +15,12 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.test_files = gem.files.grep(%r{^(spec)/})
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
gem.license = "MIT"
|
18
|
-
gem.add_dependency "
|
19
|
-
gem.
|
18
|
+
gem.add_dependency "activesupport"
|
19
|
+
gem.add_development_dependency "brotli"
|
20
20
|
gem.add_development_dependency "rspec"
|
21
|
+
gem.add_development_dependency "railties"
|
22
|
+
gem.add_development_dependency "activemodel"
|
23
|
+
gem.add_development_dependency "actionpack"
|
21
24
|
gem.add_development_dependency "redis"
|
22
25
|
gem.add_development_dependency "dalli"
|
23
26
|
gem.add_development_dependency "byebug"
|
@@ -21,7 +21,12 @@ Bundler.require(*Rails.groups)
|
|
21
21
|
module Dummy
|
22
22
|
class Application < Rails::Application
|
23
23
|
# Initialize configuration defaults for originally generated Rails version.
|
24
|
-
|
24
|
+
|
25
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
|
26
|
+
config.load_defaults 7.0
|
27
|
+
else
|
28
|
+
config.load_defaults 6.0
|
29
|
+
end
|
25
30
|
|
26
31
|
# Configuration for the application, engines, and railties goes here.
|
27
32
|
#
|
@@ -19,7 +19,7 @@ Rails.application.configure do
|
|
19
19
|
|
20
20
|
# Enable/disable caching. By default caching is disabled.
|
21
21
|
# Run rails dev:cache to toggle caching.
|
22
|
-
config.cache_store = $
|
22
|
+
config.cache_store = $test_rails_cache_store
|
23
23
|
|
24
24
|
# Print deprecation notices to the Rails logger.
|
25
25
|
config.active_support.deprecation = :log
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
return unless ENV['
|
5
|
+
return unless ENV['TEST_RAILS_CACHE_STORE'] == 'redis_cache_store'
|
6
6
|
|
7
7
|
describe RailsBrotliCache do
|
8
8
|
class Post
|
@@ -20,7 +20,7 @@ describe RailsBrotliCache do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
let(:redis_store) do
|
23
|
-
ActiveSupport::Cache::RedisCacheStore.new({ redis: $redis }.merge(options))
|
23
|
+
ActiveSupport::Cache::RedisCacheStore.new(**{ redis: $redis }.merge(options))
|
24
24
|
end
|
25
25
|
|
26
26
|
let(:brotli_store) do
|
@@ -75,7 +75,6 @@ describe RailsBrotliCache do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
context "custom namespace proc" do
|
78
|
-
@@counter = 0
|
79
78
|
let(:options) do
|
80
79
|
{
|
81
80
|
namespace: -> { "myapp" }
|
data/spec/spec_helper.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
|
-
require
|
3
|
+
require "active_support"
|
4
|
+
require "active_support/core_ext/hash"
|
4
5
|
require 'redis'
|
5
6
|
|
6
7
|
require_relative '../lib/rails-brotli-cache'
|
7
8
|
|
8
9
|
$redis = Redis.new
|
9
|
-
$
|
10
|
+
$test_rails_cache_store = if ENV['TEST_RAILS_CACHE_STORE'] == 'redis_cache_store'
|
10
11
|
ActiveSupport::Cache::RedisCacheStore.new(redis: $redis)
|
11
|
-
elsif ENV['
|
12
|
+
elsif ENV['TEST_RAILS_CACHE_STORE'] == 'brotli_cache_store'
|
12
13
|
RailsBrotliCache::Store.new(ActiveSupport::Cache::MemoryStore.new)
|
14
|
+
elsif ENV['TEST_RAILS_CACHE_STORE'] == 'memcache_cache_store'
|
15
|
+
ActiveSupport::Cache::ActiveSupport::Cache::MemCacheStore.new
|
13
16
|
else
|
14
17
|
ActiveSupport::Cache::MemoryStore.new
|
15
18
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-brotli-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pawurb
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
|
-
type: :
|
34
|
+
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
@@ -52,6 +52,48 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: railties
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activemodel
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: actionpack
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
55
97
|
- !ruby/object:Gem::Dependency
|
56
98
|
name: redis
|
57
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,7 +144,7 @@ executables: []
|
|
102
144
|
extensions: []
|
103
145
|
extra_rdoc_files: []
|
104
146
|
files:
|
105
|
-
- ".
|
147
|
+
- ".github/workflows/ci.yml"
|
106
148
|
- ".gitignore"
|
107
149
|
- Gemfile
|
108
150
|
- LICENSE.txt
|
@@ -169,7 +211,7 @@ licenses:
|
|
169
211
|
- MIT
|
170
212
|
metadata:
|
171
213
|
rubygems_mfa_required: 'true'
|
172
|
-
post_install_message:
|
214
|
+
post_install_message:
|
173
215
|
rdoc_options: []
|
174
216
|
require_paths:
|
175
217
|
- lib
|
@@ -184,8 +226,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
226
|
- !ruby/object:Gem::Version
|
185
227
|
version: '0'
|
186
228
|
requirements: []
|
187
|
-
rubygems_version: 3.
|
188
|
-
signing_key:
|
229
|
+
rubygems_version: 3.4.10
|
230
|
+
signing_key:
|
189
231
|
specification_version: 4
|
190
232
|
summary: Drop-in enhancement for Rails cache, offering better performance and compression
|
191
233
|
with Brotli algorithm.
|
data/.circleci/config.yml
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
version: 2
|
2
|
-
jobs:
|
3
|
-
test:
|
4
|
-
docker:
|
5
|
-
- image: cimg/ruby:2.7.6
|
6
|
-
- image: redis:alpine
|
7
|
-
- image: memcached:alpine
|
8
|
-
parallelism: 1
|
9
|
-
steps:
|
10
|
-
- checkout
|
11
|
-
- run: gem update --system
|
12
|
-
- run: gem install bundler
|
13
|
-
- run: sudo apt-get update --allow-releaseinfo-change
|
14
|
-
- run: bundle config set --local path 'vendor/bundle'
|
15
|
-
- run: bundle install
|
16
|
-
- run: sleep 5
|
17
|
-
- run:
|
18
|
-
name: Run specs for redis cache store
|
19
|
-
environment:
|
20
|
-
TEST_CACHE_STORE: redis_cache_store
|
21
|
-
command: bundle exec rspec spec/
|
22
|
-
- run:
|
23
|
-
name: Run specs for memcached cache store
|
24
|
-
environment:
|
25
|
-
TEST_CACHE_STORE: mem_cache_store
|
26
|
-
command: bundle exec rspec spec/
|
27
|
-
- run:
|
28
|
-
name: Run specs for in-memory cache store
|
29
|
-
command: bundle exec rspec spec/
|
30
|
-
workflows:
|
31
|
-
version: 2
|
32
|
-
test:
|
33
|
-
jobs:
|
34
|
-
- test
|