leveled_cache 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Appraisals +1 -1
- data/CHANGELOG.md +6 -1
- data/Gemfile +1 -3
- data/Rakefile +2 -5
- data/gemfiles/activesupport_6.1.gemfile +1 -3
- data/gemfiles/activesupport_7.0.gemfile +1 -3
- data/gemfiles/activesupport_7.1.gemfile +1 -3
- data/gemfiles/activesupport_7.2.gemfile +11 -0
- data/gemfiles/activesupport_main.gemfile +1 -3
- data/lib/leveled_cache/store.rb +62 -12
- data/lib/leveled_cache/version.rb +1 -1
- data/lib/leveled_cache.rb +1 -0
- metadata +10 -10
- data/.rubocop.yml +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a1044673841aded566b48eb3bd310619dca57ce3f2722768e9c47c9379bd68b
|
4
|
+
data.tar.gz: a3dcc54d533abbc3ed3ab89d08bd851b62de5c2461af683523ca26f7ef5d2e83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8317ac588eb5d751c96558c8f4c9fde807a98f6cc19265dab01a2e8c776a89133e1805fb438899d40b1fa3638c21581a46d2fc489cdb054e15bab3335792e7b5
|
7
|
+
data.tar.gz: c52bf449a0276e50e7b57627aff77ccf9916a3b3bf8c1d9b03c886706ec4fa37e039a223ea985b28e74fc1442a2161a499dd0270dbd504b5037f4549fdda6cd5
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -2,11 +2,8 @@
|
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
require "rspec/core/rake_task"
|
5
|
+
require "standard/rake"
|
5
6
|
|
6
7
|
RSpec::Core::RakeTask.new(:spec)
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
RuboCop::RakeTask.new
|
11
|
-
|
12
|
-
task default: %i[spec rubocop]
|
9
|
+
task default: %i[spec standard]
|
@@ -5,9 +5,7 @@ source "https://rubygems.org"
|
|
5
5
|
gem "appraisal"
|
6
6
|
gem "rake", "~> 13.0"
|
7
7
|
gem "rspec", "~> 3.0"
|
8
|
-
gem "
|
9
|
-
gem "rubocop-rake", "~> 0"
|
10
|
-
gem "rubocop-rspec", "~> 2.0"
|
8
|
+
gem "standardrb", "~> 1"
|
11
9
|
gem "activesupport", "~> 6.1.0"
|
12
10
|
|
13
11
|
gemspec path: "../"
|
@@ -5,9 +5,7 @@ source "https://rubygems.org"
|
|
5
5
|
gem "appraisal"
|
6
6
|
gem "rake", "~> 13.0"
|
7
7
|
gem "rspec", "~> 3.0"
|
8
|
-
gem "
|
9
|
-
gem "rubocop-rake", "~> 0"
|
10
|
-
gem "rubocop-rspec", "~> 2.0"
|
8
|
+
gem "standardrb", "~> 1"
|
11
9
|
gem "activesupport", "~> 7.0.0"
|
12
10
|
|
13
11
|
gemspec path: "../"
|
@@ -5,9 +5,7 @@ source "https://rubygems.org"
|
|
5
5
|
gem "appraisal"
|
6
6
|
gem "rake", "~> 13.0"
|
7
7
|
gem "rspec", "~> 3.0"
|
8
|
-
gem "
|
9
|
-
gem "rubocop-rake", "~> 0"
|
10
|
-
gem "rubocop-rspec", "~> 2.0"
|
8
|
+
gem "standardrb", "~> 1"
|
11
9
|
gem "activesupport", "~> 7.1.0"
|
12
10
|
|
13
11
|
gemspec path: "../"
|
@@ -5,9 +5,7 @@ source "https://rubygems.org"
|
|
5
5
|
gem "appraisal"
|
6
6
|
gem "rake", "~> 13.0"
|
7
7
|
gem "rspec", "~> 3.0"
|
8
|
-
gem "
|
9
|
-
gem "rubocop-rake", "~> 0"
|
10
|
-
gem "rubocop-rspec", "~> 2.0"
|
8
|
+
gem "standardrb", "~> 1"
|
11
9
|
gem "activesupport", git: "https://github.com/rails/rails", glob: "activesupport/*.gemspec"
|
12
10
|
|
13
11
|
gemspec path: "../"
|
data/lib/leveled_cache/store.rb
CHANGED
@@ -22,8 +22,6 @@ module LeveledCache
|
|
22
22
|
# care to configure underlying caches accordingly. For example, it may
|
23
23
|
# be desirable to use NullCoder on an earlier MemoryStore.
|
24
24
|
class Store < ActiveSupport::Cache::Store
|
25
|
-
VERSION = "0.1.0"
|
26
|
-
|
27
25
|
# Create a new LeveledCacheProxy that calls cache methods on
|
28
26
|
# one or more underlying caches in order.
|
29
27
|
#
|
@@ -72,6 +70,15 @@ module LeveledCache
|
|
72
70
|
read_entry(name, **options)
|
73
71
|
end
|
74
72
|
|
73
|
+
# Reads data from the caches in order using the given keys. Data
|
74
|
+
# is returned from the first cache level with data for a key.
|
75
|
+
# Otherwise, +{}+ is returned.
|
76
|
+
#
|
77
|
+
# Options are passed through to the underlying caches.
|
78
|
+
def read_multi(*names, **options)
|
79
|
+
read_multi_entries(names, **options)
|
80
|
+
end
|
81
|
+
|
75
82
|
# Writes the value to all cache levels with the provided key.
|
76
83
|
#
|
77
84
|
# Options are passed through to the underlying caches.
|
@@ -79,6 +86,20 @@ module LeveledCache
|
|
79
86
|
write_entry(name, value, **options)
|
80
87
|
end
|
81
88
|
|
89
|
+
# Deletes the value from all cache levels with the provided key.
|
90
|
+
#
|
91
|
+
# Options are passed through to the underlying caches.
|
92
|
+
def delete(name, **options)
|
93
|
+
delete_entry(name, **options)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Writes the key value pairs to all cache levels.
|
97
|
+
#
|
98
|
+
# Options are passed through to the underlying caches.
|
99
|
+
def write_multi(hash, **options)
|
100
|
+
write_multi_entries(hash, **options)
|
101
|
+
end
|
102
|
+
|
82
103
|
private
|
83
104
|
|
84
105
|
# Recursively `fetch_multi` on each cache. Missing values
|
@@ -87,17 +108,22 @@ module LeveledCache
|
|
87
108
|
def _fetch_multi(caches, names, options, &)
|
88
109
|
first, *rest = caches
|
89
110
|
|
90
|
-
reads = first.
|
111
|
+
reads = if first.is_a?(self.class)
|
112
|
+
first.fetch_multi(*names, **options, &)
|
113
|
+
else
|
114
|
+
first.read_multi(*names, **options)
|
115
|
+
end
|
116
|
+
|
91
117
|
missing = names - reads.keys
|
92
118
|
|
93
119
|
if missing.any?
|
94
120
|
writes = if rest.any?
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
121
|
+
_fetch_multi(rest, missing, options, &)
|
122
|
+
else
|
123
|
+
missing.index_with(&)
|
124
|
+
end
|
99
125
|
|
100
|
-
first.write_multi(writes, options)
|
126
|
+
first.write_multi(writes, **options)
|
101
127
|
reads.merge!(writes)
|
102
128
|
end
|
103
129
|
|
@@ -109,7 +135,7 @@ module LeveledCache
|
|
109
135
|
def _fetch(caches, name, options, &block)
|
110
136
|
first, *rest = caches
|
111
137
|
|
112
|
-
first.fetch(name, options) do
|
138
|
+
first.fetch(name, **options) do
|
113
139
|
if rest.any?
|
114
140
|
_fetch(rest, name, options, &block)
|
115
141
|
else
|
@@ -120,19 +146,43 @@ module LeveledCache
|
|
120
146
|
|
121
147
|
def read_entry(key, **options)
|
122
148
|
@caches.lazy.map do |cache|
|
123
|
-
cache.read(key, options)
|
149
|
+
cache.read(key, **options)
|
124
150
|
end.compact.first
|
125
151
|
end
|
126
152
|
|
127
153
|
def write_entry(key, entry, **options)
|
128
154
|
@caches.map do |cache|
|
129
|
-
cache.write(key, entry, options)
|
155
|
+
cache.write(key, entry, **options)
|
130
156
|
end
|
131
157
|
end
|
132
158
|
|
133
159
|
def delete_entry(key, **options)
|
134
160
|
@caches.map do |cache|
|
135
|
-
cache.delete(key, options)
|
161
|
+
cache.delete(key, **options)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def read_multi_entries(*keys, **options)
|
166
|
+
_read_multi_entries(@caches, *keys, **options)
|
167
|
+
end
|
168
|
+
|
169
|
+
def _read_multi_entries(caches, keys, **options)
|
170
|
+
first, *rest = caches
|
171
|
+
|
172
|
+
reads = first.read_multi(*keys, **options)
|
173
|
+
|
174
|
+
missing = keys - reads.keys
|
175
|
+
|
176
|
+
if missing.any? && rest.any?
|
177
|
+
reads.merge!(_read_multi_entries(rest, missing, **options))
|
178
|
+
end
|
179
|
+
|
180
|
+
reads
|
181
|
+
end
|
182
|
+
|
183
|
+
def write_multi_entries(hash, **options)
|
184
|
+
@caches.map do |cache|
|
185
|
+
cache.write_multi(hash)
|
136
186
|
end
|
137
187
|
end
|
138
188
|
end
|
data/lib/leveled_cache.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leveled_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Pirotte
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '6.1'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,8 +29,8 @@ dependencies:
|
|
29
29
|
version: '6.1'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
33
|
-
description:
|
32
|
+
version: '8.0'
|
33
|
+
description:
|
34
34
|
email:
|
35
35
|
- dpirotte@gmail.com
|
36
36
|
executables: []
|
@@ -38,7 +38,6 @@ extensions: []
|
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
40
40
|
- ".rspec"
|
41
|
-
- ".rubocop.yml"
|
42
41
|
- Appraisals
|
43
42
|
- CHANGELOG.md
|
44
43
|
- CODE_OF_CONDUCT.md
|
@@ -49,6 +48,7 @@ files:
|
|
49
48
|
- gemfiles/activesupport_6.1.gemfile
|
50
49
|
- gemfiles/activesupport_7.0.gemfile
|
51
50
|
- gemfiles/activesupport_7.1.gemfile
|
51
|
+
- gemfiles/activesupport_7.2.gemfile
|
52
52
|
- gemfiles/activesupport_main.gemfile
|
53
53
|
- lib/active_support/cache/leveled_cache_store.rb
|
54
54
|
- lib/leveled_cache.rb
|
@@ -62,7 +62,7 @@ metadata:
|
|
62
62
|
rubygems_mfa_required: 'true'
|
63
63
|
source_code_uri: https://github.com/dpirotte/leveled_cache
|
64
64
|
changelog_uri: https://github.com/dpirotte/leveled_cache/blob/main/CHANGELOG.md
|
65
|
-
post_install_message:
|
65
|
+
post_install_message:
|
66
66
|
rdoc_options: []
|
67
67
|
require_paths:
|
68
68
|
- lib
|
@@ -77,8 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
81
|
-
signing_key:
|
80
|
+
rubygems_version: 3.3.23
|
81
|
+
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: ActiveSupport::Cache that wraps multiple levels of caches
|
84
84
|
test_files: []
|
data/.rubocop.yml
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require:
|
2
|
-
- rubocop-rake
|
3
|
-
- rubocop-rspec
|
4
|
-
|
5
|
-
AllCops:
|
6
|
-
NewCops: enable
|
7
|
-
TargetRubyVersion: 3.1
|
8
|
-
|
9
|
-
Bundler/OrderedGems:
|
10
|
-
Exclude:
|
11
|
-
- gemfiles/*
|
12
|
-
|
13
|
-
Metrics/BlockLength:
|
14
|
-
Max: 200
|
15
|
-
|
16
|
-
Metrics/MethodLength:
|
17
|
-
Max: 16
|
18
|
-
|
19
|
-
Style/ArgumentsForwarding:
|
20
|
-
UseAnonymousForwarding: false
|
21
|
-
|
22
|
-
Style/FrozenStringLiteralComment:
|
23
|
-
Exclude:
|
24
|
-
- gemfiles/*
|
25
|
-
|
26
|
-
Style/StringLiterals:
|
27
|
-
Enabled: true
|
28
|
-
EnforcedStyle: double_quotes
|
29
|
-
|
30
|
-
Style/StringLiteralsInInterpolation:
|
31
|
-
Enabled: true
|
32
|
-
EnforcedStyle: double_quotes
|
33
|
-
|
34
|
-
Layout/LineLength:
|
35
|
-
Max: 120
|
36
|
-
|
37
|
-
Lint/MissingSuper:
|
38
|
-
Enabled: false
|
39
|
-
|
40
|
-
RSpec/ExampleLength:
|
41
|
-
Max: 7
|
42
|
-
|
43
|
-
RSpec/MessageSpies:
|
44
|
-
EnforcedStyle: receive
|
45
|
-
|
46
|
-
RSpec/MultipleExpectations:
|
47
|
-
Max: 5
|
48
|
-
|
49
|
-
RSpec/MultipleMemoizedHelpers:
|
50
|
-
Max: 6
|