rails-brotli-cache 0.4.5 → 0.5.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/Rakefile +1 -1
- data/benchmarks/main.rb +2 -1
- data/lib/rails-brotli-cache/store.rb +2 -2
- data/lib/rails-brotli-cache/version.rb +1 -1
- data/rails-brotli-cache.gemspec +4 -1
- 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/rails-brotli-cache/store_spec.rb +9 -0
- data/spec/spec_helper.rb +6 -3
- metadata +50 -8
- 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: e5fcc9aa5854debba71fab6f5df69615ab2b9edaa6620ae139e7c68c598c0dcb
|
4
|
+
data.tar.gz: a60ba10b497f50e751ca191ce8e9034bd45b30c93e3dff718a26c14e178ffed9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 066d33ad8b2e12d2fa4242ac120cbd0cd1ceee693619146d72b2dfe95ecd8dfe69b5b01028488a31e5373c5472602c42219cb2e0e749d9a2661c0cbcc26b9cb1
|
7
|
+
data.tar.gz: a8522dff7f3452c216803cf5a45c62eb0ba1acadc3d4efece1130c35574344d4b2509938a076f78293814c271376b576973135791fc5fdf342240d587a2783cc
|
@@ -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/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
@@ -124,8 +124,8 @@ module RailsBrotliCache
|
|
124
124
|
@core_store.delete(expanded_cache_key(name), options)
|
125
125
|
end
|
126
126
|
|
127
|
-
def clear
|
128
|
-
@core_store.clear
|
127
|
+
def clear(options = {})
|
128
|
+
@core_store.clear(**options)
|
129
129
|
end
|
130
130
|
|
131
131
|
def increment(name, amount = 1, **options)
|
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 "
|
18
|
+
gem.add_dependency "activesupport"
|
19
19
|
gem.add_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" }
|
@@ -211,4 +211,13 @@ describe RailsBrotliCache do
|
|
211
211
|
expect(cache_store.read("test-key")).to eq nil
|
212
212
|
end
|
213
213
|
end
|
214
|
+
|
215
|
+
describe "#clear" do
|
216
|
+
it "clears the cache" do
|
217
|
+
expect(cache_store.write("test-key", 1234))
|
218
|
+
expect(cache_store.read("test-key")).to eq 1234
|
219
|
+
cache_store.clear
|
220
|
+
expect(cache_store.read("test-key")).to eq nil
|
221
|
+
end
|
222
|
+
end
|
214
223
|
end
|
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.5.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-08-19 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
|
- - ">="
|
@@ -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
|