double_write_cache_stores 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.codeclimate.yml +7 -0
- data/.github/workflows/test.yml +60 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +91 -0
- data/.ruby-version +1 -0
- data/Appraisals +18 -0
- data/Gemfile +1 -1
- data/README.md +27 -12
- data/Rakefile +6 -1
- data/activesupport.gemfile +7 -0
- data/activesupport.gemfile.lock +62 -0
- data/compose.yaml +9 -0
- data/double_write_cache_stores.gemspec +13 -11
- data/gemfiles/activesupport_5_2.gemfile +7 -0
- data/gemfiles/activesupport_6_0.gemfile +7 -0
- data/gemfiles/activesupport_6_1.gemfile +7 -0
- data/gemfiles/activesupport_7_0.gemfile +7 -0
- data/gemfiles/without_activesupport.gemfile +5 -0
- data/lib/double_write_cache_stores/client.rb +171 -179
- data/lib/double_write_cache_stores/version.rb +1 -1
- data/lib/double_write_cache_stores.rb +22 -3
- data/lib/mem_cache_store_patch.rb +13 -0
- data/spec/double_write_cache_stores/client_spec.rb +238 -154
- data/spec/double_write_cache_stores_spec.rb +2 -2
- data/spec/spec_helper.rb +5 -26
- metadata +50 -39
- data/.travis.yml +0 -3
- data/lib/dalli_store_patch.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '09e3ef0241622ad655a775f6eb0cbb8ad558449935e2fcc3e023f1ab9afcc3b7'
|
4
|
+
data.tar.gz: 0ab94920920dc1d8debbae83a303a647a8730b8a066755990274b76498a6bae8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f728dd727b40ad69ce8238fcfe9c0ca8826612c16bdf8b7a870c4396a2eab3991a388b436d2fdd03ccefa913b6343603e114f5b408fe40f92949d4ff5218bec8
|
7
|
+
data.tar.gz: 05004ee53248b487720fb6fff66f57288ab05090a94904f1a7ce52fce11c62cf3d630b038a7d45a793659845b259f91e340ab07197a80f168abf5d5b1e663548
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
pull_request:
|
6
|
+
|
7
|
+
concurrency:
|
8
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
9
|
+
cancel-in-progress: true
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
test:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
strategy:
|
15
|
+
fail-fast: false
|
16
|
+
matrix:
|
17
|
+
ruby:
|
18
|
+
- "2.5"
|
19
|
+
- "2.6"
|
20
|
+
- "2.7"
|
21
|
+
- "3.0"
|
22
|
+
- "3.1"
|
23
|
+
- "3.2"
|
24
|
+
gemfile:
|
25
|
+
- gemfiles/activesupport_5_2.gemfile
|
26
|
+
- gemfiles/activesupport_6_0.gemfile
|
27
|
+
- gemfiles/activesupport_6_1.gemfile
|
28
|
+
- gemfiles/activesupport_7_0.gemfile
|
29
|
+
- gemfiles/without_activesupport.gemfile
|
30
|
+
exclude:
|
31
|
+
- ruby: "2.5"
|
32
|
+
gemfile: gemfiles/activesupport_7_0.gemfile
|
33
|
+
- ruby: "2.6"
|
34
|
+
gemfile: gemfiles/activesupport_7_0.gemfile
|
35
|
+
- ruby: "3.0"
|
36
|
+
gemfile: gemfiles/activesupport_5_2.gemfile
|
37
|
+
- ruby: "3.0"
|
38
|
+
gemfile: gemfiles/activesupport_5_2.gemfile
|
39
|
+
- ruby: "3.1"
|
40
|
+
gemfile: gemfiles/activesupport_5_2.gemfile
|
41
|
+
- ruby: "3.2"
|
42
|
+
gemfile: gemfiles/activesupport_5_2.gemfile
|
43
|
+
services:
|
44
|
+
memcached_11211:
|
45
|
+
image: memcached
|
46
|
+
ports:
|
47
|
+
- 11211:11211
|
48
|
+
memcached_21211:
|
49
|
+
image: memcached
|
50
|
+
ports:
|
51
|
+
- 21211:11211
|
52
|
+
env:
|
53
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
54
|
+
steps:
|
55
|
+
- uses: actions/checkout@v4
|
56
|
+
- uses: ruby/setup-ruby@v1
|
57
|
+
with:
|
58
|
+
ruby-version: ${{ matrix.ruby }}
|
59
|
+
bundler-cache: true
|
60
|
+
- run: bundle exec rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- "vendor/**/*"
|
4
|
+
DisplayCopNames: true
|
5
|
+
NewCops: disable
|
6
|
+
TargetRubyVersion: 2.5
|
7
|
+
SuggestExtensions: false
|
8
|
+
|
9
|
+
Style/AsciiComments:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Style/Documentation:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Layout/ExtraSpacing:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/GuardClause:
|
19
|
+
MinBodyLength: 5
|
20
|
+
|
21
|
+
Style/MethodDefParentheses:
|
22
|
+
EnforcedStyle: require_parentheses
|
23
|
+
|
24
|
+
Style/ModuleFunction:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Style/StringLiterals:
|
28
|
+
EnforcedStyle: double_quotes
|
29
|
+
|
30
|
+
Layout/SpaceBeforeFirstArg:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Layout/IndentationConsistency:
|
34
|
+
EnforcedStyle: indented_internal_methods
|
35
|
+
|
36
|
+
Style/SignalException:
|
37
|
+
EnforcedStyle: only_raise
|
38
|
+
|
39
|
+
Style/HashSyntax:
|
40
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
41
|
+
Exclude:
|
42
|
+
- "**/*.rake"
|
43
|
+
- "Rakefile"
|
44
|
+
|
45
|
+
Layout/LineLength:
|
46
|
+
Max: 160
|
47
|
+
|
48
|
+
Style/NumericLiterals:
|
49
|
+
MinDigits: 7
|
50
|
+
|
51
|
+
Lint/AssignmentInCondition:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
Layout/BlockAlignment:
|
55
|
+
Enabled: false
|
56
|
+
|
57
|
+
Metrics/MethodLength:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
Style/FrozenStringLiteralComment:
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
Style/NestedParenthesizedCalls:
|
64
|
+
Enabled: false
|
65
|
+
|
66
|
+
Metrics/BlockLength:
|
67
|
+
Enabled: false
|
68
|
+
|
69
|
+
Layout/EmptyLineAfterGuardClause:
|
70
|
+
Enabled: false
|
71
|
+
|
72
|
+
Style/MutableConstant:
|
73
|
+
Enabled: false
|
74
|
+
|
75
|
+
Style/ExpandPathArguments:
|
76
|
+
Enabled: false
|
77
|
+
|
78
|
+
Style/Alias:
|
79
|
+
Enabled: false
|
80
|
+
|
81
|
+
Style/SafeNavigation:
|
82
|
+
Enabled: false
|
83
|
+
|
84
|
+
Style/IfUnlessModifier:
|
85
|
+
Enabled: false
|
86
|
+
|
87
|
+
Style/ExplicitBlockArgument:
|
88
|
+
Enabled: false
|
89
|
+
|
90
|
+
Lint/AmbiguousBlockAssociation:
|
91
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.3
|
data/Appraisals
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
appraise "without_activesupport" do
|
2
|
+
end
|
3
|
+
|
4
|
+
appraise "activesupport_5_2" do
|
5
|
+
gem "activesupport", "~> 5.2.8.1"
|
6
|
+
end
|
7
|
+
|
8
|
+
appraise "activesupport_6_0" do
|
9
|
+
gem "activesupport", "~> 6.0.6.1"
|
10
|
+
end
|
11
|
+
|
12
|
+
appraise "activesupport_6_1" do
|
13
|
+
gem "activesupport", "~> 6.1.7.7"
|
14
|
+
end
|
15
|
+
|
16
|
+
appraise "activesupport_7_0" do
|
17
|
+
gem "activesupport", "~> 7.0.8.1"
|
18
|
+
end
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,17 +1,13 @@
|
|
1
1
|
# DoubleWriteCacheStores
|
2
2
|
|
3
|
-
|
3
|
+
[![test](https://github.com/mixigroup/double_write_cache_stores/actions/workflows/test.yml/badge.svg)](https://github.com/mixigroup/double_write_cache_stores/actions/workflows/test.yml)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
- Padrino::Cache(moneta)
|
8
|
-
- ActiveSupport::Cache::DalliStore(Dalli)
|
9
|
-
- Padrino::Cache::Store::Memcache
|
5
|
+
pre-warming(double write to cach store and other cache store) cache store wrapper. will switch cache store.
|
10
6
|
|
11
7
|
## Support backend cache store
|
12
8
|
|
13
|
-
- ActiveSupport::Cache::
|
14
|
-
-
|
9
|
+
- ActiveSupport::Cache::MemCacheStore
|
10
|
+
- Dalli::Client
|
15
11
|
|
16
12
|
## Installation
|
17
13
|
|
@@ -32,6 +28,7 @@ Or install it yourself as:
|
|
32
28
|
### Padrino
|
33
29
|
|
34
30
|
`config/apps.rb`
|
31
|
+
|
35
32
|
````
|
36
33
|
read_and_write_cache_store = ActiveSupport::Cache.lookup_store :dalli_store, 'localhost:11211'
|
37
34
|
write_only_cache_store = ActiveSupport::Cache.lookup_store :dalli_store, 'localhost:21211'
|
@@ -44,10 +41,14 @@ set :cache, DoubleWriteCacheStores::Client.new(read_and_write_cache_store, write
|
|
44
41
|
`config/application.rb`
|
45
42
|
|
46
43
|
```ruby
|
47
|
-
|
48
|
-
|
44
|
+
options = { expires_in: 1.week, compress: true }
|
45
|
+
|
46
|
+
read_and_write_cache_store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost:11211", options
|
47
|
+
config.middleware.insert_before "Rack::Runtime", read_and_write_cache_store.middleware
|
48
|
+
|
49
|
+
write_only_cache_store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost:21211", options
|
49
50
|
|
50
|
-
config.cache_store = DoubleWriteCacheStores::Client.new
|
51
|
+
config.cache_store = DoubleWriteCacheStores::Client.new read_and_write_cache_store, write_only_cache_store
|
51
52
|
```
|
52
53
|
|
53
54
|
#### in application
|
@@ -58,9 +59,23 @@ Rails.cache.fetch("key") do
|
|
58
59
|
end
|
59
60
|
```
|
60
61
|
|
62
|
+
## Run tests locally
|
63
|
+
|
64
|
+
```
|
65
|
+
docker compose up -d
|
66
|
+
bundle install
|
67
|
+
bundle exec appraisal install
|
68
|
+
bundle exec appraisal activesupport_7_0 rake
|
69
|
+
|
70
|
+
#bundle exec appraisal activesupport_5_2 rake
|
71
|
+
#bundle exec appraisal activesupport_6_0 rake
|
72
|
+
#bundle exec appraisal activesupport_6_1 rake
|
73
|
+
#bundle exec appraisal without_activesupport rake
|
74
|
+
```
|
75
|
+
|
61
76
|
## Contributing
|
62
77
|
|
63
|
-
1. Fork it ( http://github.com/
|
78
|
+
1. Fork it ( http://github.com/mixigroup/double_write_cache_stores/fork )
|
64
79
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
80
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
66
81
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
+
require "rubocop/rake_task"
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
5
6
|
|
6
|
-
|
7
|
+
RuboCop::RakeTask.new do |task|
|
8
|
+
task.options = %w[-c .rubocop.yml]
|
9
|
+
end
|
10
|
+
|
11
|
+
task default: %i[rubocop spec]
|
@@ -0,0 +1,62 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
double_write_cache_stores (0.4.0)
|
5
|
+
dalli (~> 2.7.4)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activesupport (4.2.4)
|
11
|
+
i18n (~> 0.7)
|
12
|
+
json (~> 1.7, >= 1.7.7)
|
13
|
+
minitest (~> 5.1)
|
14
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
coderay (1.1.0)
|
17
|
+
dalli (2.7.4)
|
18
|
+
diff-lcs (1.2.5)
|
19
|
+
i18n (0.7.0)
|
20
|
+
json (1.8.3)
|
21
|
+
method_source (0.8.2)
|
22
|
+
minitest (5.8.2)
|
23
|
+
pry (0.10.3)
|
24
|
+
coderay (~> 1.1.0)
|
25
|
+
method_source (~> 0.8.1)
|
26
|
+
slop (~> 3.4)
|
27
|
+
rack (1.6.4)
|
28
|
+
rake (10.4.2)
|
29
|
+
rspec (3.3.0)
|
30
|
+
rspec-core (~> 3.3.0)
|
31
|
+
rspec-expectations (~> 3.3.0)
|
32
|
+
rspec-mocks (~> 3.3.0)
|
33
|
+
rspec-core (3.3.2)
|
34
|
+
rspec-support (~> 3.3.0)
|
35
|
+
rspec-expectations (3.3.1)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.3.0)
|
38
|
+
rspec-mocks (3.3.2)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.3.0)
|
41
|
+
rspec-support (3.3.0)
|
42
|
+
slop (3.6.0)
|
43
|
+
thread_safe (0.3.5)
|
44
|
+
tilt (1.3.7)
|
45
|
+
tzinfo (1.2.2)
|
46
|
+
thread_safe (~> 0.1)
|
47
|
+
|
48
|
+
PLATFORMS
|
49
|
+
ruby
|
50
|
+
|
51
|
+
DEPENDENCIES
|
52
|
+
activesupport
|
53
|
+
bundler (~> 1.5)
|
54
|
+
double_write_cache_stores!
|
55
|
+
pry
|
56
|
+
rack
|
57
|
+
rake
|
58
|
+
rspec
|
59
|
+
tilt (= 1.3.7)
|
60
|
+
|
61
|
+
BUNDLED WITH
|
62
|
+
1.10.6
|
data/compose.yaml
ADDED
@@ -1,29 +1,31 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
3
|
+
require "double_write_cache_stores/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
6
|
spec.name = "double_write_cache_stores"
|
8
7
|
spec.version = DoubleWriteCacheStores::VERSION
|
9
8
|
spec.authors = ["hirocaster"]
|
10
9
|
spec.email = ["hohtsuka@gmail.com"]
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
10
|
+
spec.summary = "Double write cache stores wrapper."
|
11
|
+
spec.description = "pre-warming(double write to cach store and other cache store) cache store wrapper. will switch cache store."
|
13
12
|
spec.homepage = ""
|
14
13
|
spec.license = "MIT"
|
15
14
|
|
16
|
-
spec.files = `git ls-files`.split(
|
15
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
18
|
spec.require_paths = ["lib"]
|
20
19
|
|
21
|
-
spec.
|
20
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5")
|
21
|
+
|
22
|
+
spec.add_runtime_dependency "dalli", "~> 3.0"
|
23
|
+
|
24
|
+
spec.add_development_dependency "appraisal", "~> 2.5.0"
|
25
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
26
|
+
spec.add_development_dependency "pry"
|
22
27
|
spec.add_development_dependency "rake"
|
23
28
|
spec.add_development_dependency "rspec"
|
24
|
-
spec.add_development_dependency "
|
25
|
-
spec.add_development_dependency "dalli", "= 2.7.0"
|
26
|
-
spec.add_development_dependency "pry"
|
27
|
-
spec.add_development_dependency "padrino", "0.10.7"
|
29
|
+
spec.add_development_dependency "rubocop"
|
28
30
|
spec.add_development_dependency "tilt", "1.3.7"
|
29
31
|
end
|