collectionspace-refcache 1.0.0 → 1.0.1
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/.github/workflows/ci.yml +1 -1
- data/.github/workflows/publish.yml +1 -1
- data/.ruby-version +1 -1
- data/Gemfile.lock +103 -49
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/bin/console +3 -3
- data/bin/rspec +1 -1
- data/collectionspace-refcache.gemspec +4 -4
- data/doc/REFCACHE.md +6 -3
- data/lib/collectionspace/refcache/backend/activesupport_cache_store.rb +57 -0
- data/lib/collectionspace/refcache/backend/redis.rb +1 -1
- data/lib/collectionspace/refcache/backend/zache.rb +1 -1
- data/lib/collectionspace/refcache/backend.rb +2 -1
- data/lib/collectionspace/refcache/refcache.rb +72 -62
- data/lib/collectionspace/refcache/version.rb +2 -2
- metadata +10 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 42e8acdba0d3c8da1fcbe7ed21f28f05e6f0218c51d271bccc653eb6bae3dc9a
|
|
4
|
+
data.tar.gz: bac0cdb617a10ccac95694d39115514df8b1b0ce0c5ff3e53fc07f22974ec61d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba1fb6fb68c059733583fce9ca8319c95e5df0d9f1aa6d1124ec83968ac09ebc0142c01de981bb2a50c5577d680fcf949763ec446a1048760e49d9abd4e91a7a
|
|
7
|
+
data.tar.gz: a6c52240d77fc9daf63115370adefe53fdefca72b8a0f16c8e7ccd60420520a8648de8f25c7133285182829537c1315644b062d07d49cb34801a491eba25d459
|
data/.github/workflows/ci.yml
CHANGED
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4.0.5
|
data/Gemfile.lock
CHANGED
|
@@ -1,77 +1,92 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
collectionspace-refcache (1.0.
|
|
4
|
+
collectionspace-refcache (1.0.1)
|
|
5
5
|
redis (~> 4.2.1)
|
|
6
6
|
zache (~> 0.12.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
ast (2.4.
|
|
11
|
+
ast (2.4.3)
|
|
12
12
|
coderay (1.1.3)
|
|
13
|
-
diff-lcs (1.
|
|
14
|
-
|
|
15
|
-
json (
|
|
16
|
-
language_server-protocol (3.17.0.
|
|
17
|
-
|
|
13
|
+
diff-lcs (1.6.2)
|
|
14
|
+
io-console (0.9.4)
|
|
15
|
+
json (3.1.0)
|
|
16
|
+
language_server-protocol (3.17.0.6)
|
|
17
|
+
lint_roller (1.1.0)
|
|
18
|
+
method_source (1.1.0)
|
|
18
19
|
mock_redis (0.29.0)
|
|
19
20
|
ruby2_keywords
|
|
20
|
-
parallel (
|
|
21
|
-
parser (3.
|
|
21
|
+
parallel (2.3.0)
|
|
22
|
+
parser (3.3.13.0)
|
|
22
23
|
ast (~> 2.4.1)
|
|
23
|
-
|
|
24
|
+
racc
|
|
25
|
+
prism (1.9.0)
|
|
26
|
+
pry (0.16.1)
|
|
24
27
|
coderay (~> 1.1)
|
|
25
28
|
method_source (~> 1.0)
|
|
29
|
+
reline (>= 0.6.0)
|
|
30
|
+
racc (1.8.1)
|
|
26
31
|
rainbow (3.1.1)
|
|
27
|
-
rake (13.
|
|
32
|
+
rake (13.4.2)
|
|
28
33
|
redis (4.2.5)
|
|
29
|
-
regexp_parser (2.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
rspec-
|
|
34
|
-
rspec-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
regexp_parser (2.13.1)
|
|
35
|
+
reline (0.7.0)
|
|
36
|
+
io-console (~> 0.5)
|
|
37
|
+
rspec (3.13.2)
|
|
38
|
+
rspec-core (~> 3.13.0)
|
|
39
|
+
rspec-expectations (~> 3.13.0)
|
|
40
|
+
rspec-mocks (~> 3.13.0)
|
|
41
|
+
rspec-core (3.13.6)
|
|
42
|
+
rspec-support (~> 3.13.0)
|
|
43
|
+
rspec-expectations (3.13.5)
|
|
38
44
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
39
|
-
rspec-support (~> 3.
|
|
40
|
-
rspec-mocks (3.
|
|
45
|
+
rspec-support (~> 3.13.0)
|
|
46
|
+
rspec-mocks (3.13.8)
|
|
41
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
42
|
-
rspec-support (~> 3.
|
|
43
|
-
rspec-support (3.
|
|
44
|
-
rubocop (1.
|
|
45
|
-
json (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
rspec-support (~> 3.13.0)
|
|
49
|
+
rspec-support (3.13.7)
|
|
50
|
+
rubocop (1.91.0)
|
|
51
|
+
json (>= 2.3)
|
|
52
|
+
language_server-protocol (~> 3.17.0.2)
|
|
53
|
+
lint_roller (~> 1.1.0)
|
|
54
|
+
parallel (>= 1.10)
|
|
55
|
+
parser (>= 3.3.0.2)
|
|
48
56
|
rainbow (>= 2.2.2, < 4.0)
|
|
49
|
-
regexp_parser (>=
|
|
50
|
-
|
|
51
|
-
rubocop-ast (>= 1.24.1, < 2.0)
|
|
57
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
58
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
52
59
|
ruby-progressbar (~> 1.7)
|
|
53
|
-
unicode-display_width (>= 2.4.0, <
|
|
54
|
-
rubocop-ast (1.
|
|
55
|
-
parser (>= 3.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
61
|
+
rubocop-ast (1.50.0)
|
|
62
|
+
parser (>= 3.3.7.2)
|
|
63
|
+
prism (~> 1.7)
|
|
64
|
+
rubocop-performance (1.26.1)
|
|
65
|
+
lint_roller (~> 1.1)
|
|
66
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
67
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
59
68
|
ruby-progressbar (1.13.0)
|
|
60
69
|
ruby2_keywords (0.0.5)
|
|
61
|
-
simplecov (
|
|
62
|
-
|
|
63
|
-
simplecov-html (~> 0.11)
|
|
64
|
-
simplecov_json_formatter (~> 0.1)
|
|
65
|
-
simplecov-html (0.12.3)
|
|
66
|
-
simplecov_json_formatter (0.1.4)
|
|
67
|
-
standard (1.24.3)
|
|
70
|
+
simplecov (1.3.2)
|
|
71
|
+
standard (1.57.0)
|
|
68
72
|
language_server-protocol (~> 3.17.0.2)
|
|
69
|
-
|
|
70
|
-
rubocop
|
|
71
|
-
|
|
73
|
+
lint_roller (~> 1.0)
|
|
74
|
+
rubocop (~> 1.91.0)
|
|
75
|
+
standard-custom (~> 1.0.0)
|
|
76
|
+
standard-performance (~> 1.8)
|
|
77
|
+
standard-custom (1.0.2)
|
|
78
|
+
lint_roller (~> 1.0)
|
|
79
|
+
rubocop (~> 1.50)
|
|
80
|
+
standard-performance (1.9.0)
|
|
81
|
+
lint_roller (~> 1.1)
|
|
82
|
+
rubocop-performance (~> 1.26.0)
|
|
83
|
+
unicode-display_width (3.3.0)
|
|
84
|
+
unicode-emoji (~> 4.3)
|
|
85
|
+
unicode-emoji (4.3.0)
|
|
72
86
|
zache (0.12.0)
|
|
73
87
|
|
|
74
88
|
PLATFORMS
|
|
89
|
+
arm64-darwin-25
|
|
75
90
|
ruby
|
|
76
91
|
|
|
77
92
|
DEPENDENCIES
|
|
@@ -81,8 +96,47 @@ DEPENDENCIES
|
|
|
81
96
|
rake (~> 13.0)
|
|
82
97
|
rspec
|
|
83
98
|
rubocop
|
|
84
|
-
simplecov
|
|
99
|
+
simplecov
|
|
85
100
|
standard
|
|
86
101
|
|
|
102
|
+
CHECKSUMS
|
|
103
|
+
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
|
|
104
|
+
coderay (1.1.3) sha256=dc530018a4684512f8f38143cd2a096c9f02a1fc2459edcfe534787a7fc77d4b
|
|
105
|
+
collectionspace-refcache (1.0.1)
|
|
106
|
+
diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
|
|
107
|
+
io-console (0.9.4) sha256=a403304f32928ee85e56d457b4612ca43f2703b561a3258844992bd24085fbb1
|
|
108
|
+
json (3.1.0) sha256=3ce7ccf8fde58960177a3a756c31f292a4c1e1dedee884547096a5b0604e3bd8
|
|
109
|
+
language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0
|
|
110
|
+
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
|
|
111
|
+
method_source (1.1.0) sha256=181301c9c45b731b4769bc81e8860e72f9161ad7d66dd99103c9ab84f560f5c5
|
|
112
|
+
mock_redis (0.29.0) sha256=296956fff24a8bf10d771e4f1a54913161de480b879f53f7ae5030aa323c5282
|
|
113
|
+
parallel (2.3.0) sha256=f75a3e904101ce6a1ccb6b8dc800cbafd42166d83330192438dcf29395167a6f
|
|
114
|
+
parser (3.3.13.0) sha256=e02f9b63c2fe05b0c68f692ba4df89b3cb113b663964f75d988fbebfd6c3deca
|
|
115
|
+
prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
|
|
116
|
+
pry (0.16.1) sha256=d92d82c86e7f2dc34beec6d2892d5cf5ea517eea22eed3ceabb38ee62a98accc
|
|
117
|
+
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
|
|
118
|
+
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
|
|
119
|
+
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
|
|
120
|
+
redis (4.2.5) sha256=88a85e4a379b8fdfdc76518dd4fd5daa34464735785ef4f6929924004dd6a297
|
|
121
|
+
regexp_parser (2.13.1) sha256=5aedb6b7c35688f51e86eef17a15374dfd287c83f4ca644b2c5f3ec50a33b44b
|
|
122
|
+
reline (0.7.0) sha256=5b012d8e55dbf9d450f12bde2cf7d15ff546ae80b3f8f3b30e570d431815583d
|
|
123
|
+
rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
|
|
124
|
+
rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
|
|
125
|
+
rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
|
|
126
|
+
rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
|
|
127
|
+
rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
|
|
128
|
+
rubocop (1.91.0) sha256=9c82b7bf391c5d7e3798c5b9996e22a1fe3bd7468e351dfdeb96140c058296d0
|
|
129
|
+
rubocop-ast (1.50.0) sha256=b9ca88300da0803ee222ad20cdb30494c0a784eed06fdc35d254b06d662788db
|
|
130
|
+
rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834
|
|
131
|
+
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
|
|
132
|
+
ruby2_keywords (0.0.5) sha256=ffd13740c573b7301cf7a2e61fc857b2a8e3d3aff32545d6f8300d8bae10e3ef
|
|
133
|
+
simplecov (1.3.2) sha256=2a22ec1759f1b8db60881a2e038758956fc69ef93ed669be0bde0678de6d0e85
|
|
134
|
+
standard (1.57.0) sha256=4a65ea92421fbaf77fb54da91e16093cf79b335b8f62c35aaa3dd714c8592858
|
|
135
|
+
standard-custom (1.0.2) sha256=424adc84179a074f1a2a309bb9cf7cd6bfdb2b6541f20c6bf9436c0ba22a652b
|
|
136
|
+
standard-performance (1.9.0) sha256=49483d31be448292951d80e5e67cdcb576c2502103c7b40aec6f1b6e9c88e3f2
|
|
137
|
+
unicode-display_width (3.3.0) sha256=4b7aa66a4b11db50f6f7e98411215cd0dd10eaecb665d36eec5bcacb3fa0b613
|
|
138
|
+
unicode-emoji (4.3.0) sha256=11c02fa73290378c066bb0562cd4c87d8e1b706fbbe0059ca12746a4244de8ce
|
|
139
|
+
zache (0.12.0) sha256=6a3bccae54ca88fa0b0afa9debdbcb30c3f3b470d8763844c10a9fa62b02bce7
|
|
140
|
+
|
|
87
141
|
BUNDLED WITH
|
|
88
|
-
|
|
142
|
+
4.0.10
|
data/README.md
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
require
|
|
5
|
-
require
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
require "collectionspace/refcache"
|
|
6
6
|
|
|
7
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
8
|
# with your gem easier. You can also use a different console, if you like.
|
|
@@ -11,5 +11,5 @@ require 'collectionspace/refcache'
|
|
|
11
11
|
# require "pry"
|
|
12
12
|
# Pry.start
|
|
13
13
|
|
|
14
|
-
require
|
|
14
|
+
require "irb"
|
|
15
15
|
IRB.start(__FILE__)
|
data/bin/rspec
CHANGED
|
@@ -15,7 +15,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
|
15
15
|
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
|
16
16
|
|
|
17
17
|
if File.file?(bundle_binstub)
|
|
18
|
-
if
|
|
18
|
+
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
|
|
19
19
|
load(bundle_binstub)
|
|
20
20
|
else
|
|
21
21
|
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
|
@@ -4,15 +4,15 @@ require_relative "lib/collectionspace/refcache/version"
|
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = "collectionspace-refcache"
|
|
7
|
-
spec.version = CollectionSpace::
|
|
7
|
+
spec.version = CollectionSpace::Refcache::VERSION
|
|
8
8
|
spec.authors = ["Mark Cooper"]
|
|
9
9
|
spec.email = ["mark.c.cooper@outlook.com"]
|
|
10
10
|
|
|
11
|
-
spec.summary = "CollectionSpace
|
|
11
|
+
spec.summary = "CollectionSpace Refcache."
|
|
12
12
|
spec.description = "A caching system for CollectionSpace refnames."
|
|
13
13
|
spec.homepage = "https://github.org/collectionspace/collectionspace-refcache"
|
|
14
14
|
spec.license = "MIT"
|
|
15
|
-
spec.required_ruby_version = ">=
|
|
15
|
+
spec.required_ruby_version = ">= 4.0.5"
|
|
16
16
|
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
18
|
spec.metadata["source_code_uri"] = spec.homepage
|
|
@@ -32,6 +32,6 @@ Gem::Specification.new do |spec|
|
|
|
32
32
|
spec.add_development_dependency("rake", "~> 13.0")
|
|
33
33
|
spec.add_development_dependency("rspec")
|
|
34
34
|
spec.add_development_dependency("rubocop")
|
|
35
|
-
spec.add_development_dependency("simplecov"
|
|
35
|
+
spec.add_development_dependency("simplecov")
|
|
36
36
|
spec.add_development_dependency("standard")
|
|
37
37
|
end
|
data/doc/REFCACHE.md
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Refcache
|
|
2
2
|
|
|
3
3
|
Setup and usage:
|
|
4
4
|
|
|
5
5
|
```ruby
|
|
6
|
+
# In-memory cache (Zache) will be used as backend if neither :redis nor :store are included
|
|
7
|
+
# in config
|
|
6
8
|
cache_config = {
|
|
7
|
-
# redis: 'redis://localhost:6379/1', # optional
|
|
9
|
+
# redis: 'redis://localhost:6379/1', # optional
|
|
10
|
+
# store: ActiveSupport::Cache::Store or SolidCache::Store object, # optional
|
|
8
11
|
domain: 'core.collectionspace.org',
|
|
9
12
|
error_if_not_found: false, # raise error if key cannot be retrieved (default false)
|
|
10
13
|
lifetime: 5 * 60, # cache expiry in seconds (default is 5 minutes)
|
|
11
14
|
}
|
|
12
|
-
cache = CollectionSpace::
|
|
15
|
+
cache = CollectionSpace::Refcache.new(config: cache_config)
|
|
13
16
|
cache.get('placeauthorities', 'place', 'Death Valley') # $refname or error / nil if not found
|
|
14
17
|
cache.exists?('placeauthorities', 'place', 'Death Valley') # check for key
|
|
15
18
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CollectionSpace
|
|
4
|
+
class Refcache
|
|
5
|
+
module Backend
|
|
6
|
+
class ActivesupportCacheStore
|
|
7
|
+
# @param store [ActiveSupport::Cache::Store] or other store conforming
|
|
8
|
+
# to its abstract interface (e.g. SolidCache::Store)
|
|
9
|
+
def initialize(store)
|
|
10
|
+
@c = store
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def clean
|
|
14
|
+
return nil unless @c.respond_to?(:clean)
|
|
15
|
+
|
|
16
|
+
@c.clean
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def connected?
|
|
20
|
+
"PONG" # cute, matches redis response
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def exists?(key)
|
|
24
|
+
@c.exist?(key)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def flush
|
|
28
|
+
return nil unless @c.respond_to?(:clear)
|
|
29
|
+
|
|
30
|
+
@c.clear
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def get(key)
|
|
34
|
+
@c.read(key)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def put(key, value, lifetime: nil)
|
|
38
|
+
if lifetime
|
|
39
|
+
@c.write(key, value, expires_in: lifetime)
|
|
40
|
+
else
|
|
41
|
+
@c.write(key, value)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def remove(key)
|
|
46
|
+
@c.delete(key)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def size
|
|
50
|
+
return nil unless @c.respond_to?(:stats)
|
|
51
|
+
|
|
52
|
+
@c.stats.dig(:connection_stats, :cache, :entries)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
require "digest"
|
|
4
4
|
|
|
5
5
|
module CollectionSpace
|
|
6
|
-
class
|
|
6
|
+
class Refcache
|
|
7
7
|
class NotFoundError < StandardError; end
|
|
8
8
|
|
|
9
9
|
attr_reader :config, :domain
|
|
10
10
|
|
|
11
11
|
def initialize(config: {})
|
|
12
12
|
@config = config
|
|
13
|
-
@cache =
|
|
13
|
+
@cache = set_backend(config)
|
|
14
14
|
@domain = config.fetch(:domain)
|
|
15
15
|
@error_if_not_found = config.fetch(:error_if_not_found, false)
|
|
16
16
|
@lifetime = config.fetch(:lifetime, 5 * 60)
|
|
@@ -43,126 +43,130 @@ module CollectionSpace
|
|
|
43
43
|
#####
|
|
44
44
|
# Default methods (assumes authority terms)
|
|
45
45
|
# cache.exists?('placeauthorities', 'place', 'Death Valley')
|
|
46
|
-
def exists?(type, subtype, value)
|
|
47
|
-
generic_exists?(term_key(type, subtype, value))
|
|
46
|
+
def exists?(type, subtype, value, value_type = nil)
|
|
47
|
+
generic_exists?(term_key(type, subtype, value, value_type))
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
# cache.put('placeauthorities', 'place', 'The Moon', $refname)
|
|
51
51
|
# rubocop:disable Metrics/ParameterLists
|
|
52
|
-
def put(type, subtype, value, to_cache)
|
|
53
|
-
put_generic(term_key(type, subtype, value), to_cache)
|
|
52
|
+
def put(type, subtype, value, to_cache, value_type = nil)
|
|
53
|
+
put_generic(term_key(type, subtype, value, value_type), to_cache)
|
|
54
54
|
end
|
|
55
55
|
# rubocop:enable Metrics/ParameterLists
|
|
56
56
|
|
|
57
57
|
# cache.get('placeauthorities', 'place', 'The Moon')
|
|
58
58
|
# cache.get('vocabularies', 'languages', 'English')
|
|
59
|
-
def get(type, subtype, value)
|
|
60
|
-
get_generic(term_key(type, subtype, value))
|
|
59
|
+
def get(type, subtype, value, value_type = nil)
|
|
60
|
+
get_generic(term_key(type, subtype, value, value_type))
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
def remove(type, subtype, value)
|
|
64
|
-
remove_generic(term_key(type, subtype, value))
|
|
63
|
+
def remove(type, subtype, value, value_type = nil)
|
|
64
|
+
remove_generic(term_key(type, subtype, value, value_type))
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
#####
|
|
68
68
|
# object caching
|
|
69
69
|
#####
|
|
70
|
-
def put_object(id, to_cache)
|
|
71
|
-
put_generic(object_key(id), to_cache)
|
|
70
|
+
def put_object(id, to_cache, value_type = nil)
|
|
71
|
+
put_generic(object_key(id, value_type), to_cache)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
def get_object(id)
|
|
75
|
-
get_generic(object_key(id))
|
|
74
|
+
def get_object(id, value_type = nil)
|
|
75
|
+
get_generic(object_key(id, value_type))
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
def remove_object(id)
|
|
79
|
-
remove_generic(object_key(id))
|
|
78
|
+
def remove_object(id, value_type = nil)
|
|
79
|
+
remove_generic(object_key(id, value_type))
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
def object_exists?(id)
|
|
83
|
-
generic_exists?(object_key(id))
|
|
82
|
+
def object_exists?(id, value_type = nil)
|
|
83
|
+
generic_exists?(object_key(id, value_type))
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
#####
|
|
87
87
|
# procedure caching
|
|
88
88
|
#####
|
|
89
|
-
def put_procedure(type, id, to_cache)
|
|
90
|
-
put_generic(procedure_key(type, id), to_cache)
|
|
89
|
+
def put_procedure(type, id, to_cache, value_type = nil)
|
|
90
|
+
put_generic(procedure_key(type, id, value_type), to_cache)
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
def get_procedure(type, id)
|
|
94
|
-
get_generic(procedure_key(type, id))
|
|
93
|
+
def get_procedure(type, id, value_type = nil)
|
|
94
|
+
get_generic(procedure_key(type, id, value_type))
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
-
def remove_procedure(type, id)
|
|
98
|
-
remove_generic(procedure_key(type, id))
|
|
97
|
+
def remove_procedure(type, id, value_type = nil)
|
|
98
|
+
remove_generic(procedure_key(type, id, value_type))
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
def procedure_exists?(type, id)
|
|
102
|
-
generic_exists?(procedure_key(type, id))
|
|
101
|
+
def procedure_exists?(type, id, value_type = nil)
|
|
102
|
+
generic_exists?(procedure_key(type, id, value_type))
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
#####
|
|
106
106
|
# authority term caching
|
|
107
107
|
#####
|
|
108
|
-
def auth_term_exists?(type, subtype, term)
|
|
109
|
-
generic_exists?(term_key(type, subtype, term))
|
|
108
|
+
def auth_term_exists?(type, subtype, term, value_type = nil)
|
|
109
|
+
generic_exists?(term_key(type, subtype, term, value_type))
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
# rubocop:disable Metrics/ParameterLists
|
|
113
|
-
def put_auth_term(type, subtype, term, to_cache)
|
|
114
|
-
put_generic(term_key(type, subtype, term), to_cache)
|
|
113
|
+
def put_auth_term(type, subtype, term, to_cache, value_type = nil)
|
|
114
|
+
put_generic(term_key(type, subtype, term, value_type), to_cache)
|
|
115
115
|
end
|
|
116
116
|
# rubocop:enable Metrics/ParameterLists
|
|
117
117
|
|
|
118
|
-
def get_auth_term(type, subtype, term)
|
|
119
|
-
get_generic(term_key(type, subtype, term))
|
|
118
|
+
def get_auth_term(type, subtype, term, value_type = nil)
|
|
119
|
+
get_generic(term_key(type, subtype, term, value_type))
|
|
120
120
|
end
|
|
121
121
|
|
|
122
|
-
def remove_auth_term(type, subtype, term)
|
|
123
|
-
remove_generic(term_key(type, subtype, term))
|
|
122
|
+
def remove_auth_term(type, subtype, term, value_type = nil)
|
|
123
|
+
remove_generic(term_key(type, subtype, term, value_type))
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
#####
|
|
127
127
|
# relation caching
|
|
128
128
|
#####
|
|
129
|
-
def relation_exists?(reltype, subjectcsid, objectcsid)
|
|
130
|
-
generic_exists?(
|
|
129
|
+
def relation_exists?(reltype, subjectcsid, objectcsid, value_type = nil)
|
|
130
|
+
generic_exists?(
|
|
131
|
+
relation_key(reltype, subjectcsid, objectcsid, value_type)
|
|
132
|
+
)
|
|
131
133
|
end
|
|
132
134
|
|
|
133
135
|
# rubocop:disable Metrics/ParameterLists
|
|
134
|
-
def put_relation(reltype, subjectcsid, objectcsid, to_cache
|
|
135
|
-
|
|
136
|
+
def put_relation(reltype, subjectcsid, objectcsid, to_cache,
|
|
137
|
+
value_type = nil)
|
|
138
|
+
put_generic(relation_key(reltype, subjectcsid, objectcsid, value_type),
|
|
139
|
+
to_cache)
|
|
136
140
|
end
|
|
137
141
|
# rubocop:enable Metrics/ParameterLists
|
|
138
142
|
|
|
139
|
-
def get_relation(reltype, subjectcsid, objectcsid)
|
|
140
|
-
get_generic(
|
|
143
|
+
def get_relation(reltype, subjectcsid, objectcsid, value_type = nil)
|
|
144
|
+
get_generic(relation_key(reltype, subjectcsid, objectcsid, value_type))
|
|
141
145
|
end
|
|
142
146
|
|
|
143
|
-
def remove_relation(reltype, subjectcsid, objectcsid)
|
|
144
|
-
remove_generic(
|
|
147
|
+
def remove_relation(reltype, subjectcsid, objectcsid, value_type = nil)
|
|
148
|
+
remove_generic(relation_key(reltype, subjectcsid, objectcsid, value_type))
|
|
145
149
|
end
|
|
146
150
|
|
|
147
151
|
#####
|
|
148
152
|
# vocabulary term caching
|
|
149
153
|
#####
|
|
150
|
-
def vocab_term_exists?(vocab, term)
|
|
151
|
-
generic_exists?(vocab_term_key(vocab, term))
|
|
154
|
+
def vocab_term_exists?(vocab, term, value_type = nil)
|
|
155
|
+
generic_exists?(vocab_term_key(vocab, term, value_type))
|
|
152
156
|
end
|
|
153
157
|
|
|
154
158
|
# rubocop:disable Metrics/ParameterLists
|
|
155
|
-
def put_vocab_term(vocab, term, to_cache)
|
|
156
|
-
put_generic(vocab_term_key(vocab, term), to_cache)
|
|
159
|
+
def put_vocab_term(vocab, term, to_cache, value_type = nil)
|
|
160
|
+
put_generic(vocab_term_key(vocab, term, value_type), to_cache)
|
|
157
161
|
end
|
|
158
162
|
# rubocop:enable Metrics/ParameterLists
|
|
159
163
|
|
|
160
|
-
def get_vocab_term(vocab, term)
|
|
161
|
-
get_generic(vocab_term_key(vocab, term))
|
|
164
|
+
def get_vocab_term(vocab, term, value_type = nil)
|
|
165
|
+
get_generic(vocab_term_key(vocab, term, value_type))
|
|
162
166
|
end
|
|
163
167
|
|
|
164
|
-
def remove_vocab_term(vocab, term)
|
|
165
|
-
remove_generic(vocab_term_key(vocab, term))
|
|
168
|
+
def remove_vocab_term(vocab, term, value_type = nil)
|
|
169
|
+
remove_generic(vocab_term_key(vocab, term, value_type))
|
|
166
170
|
end
|
|
167
171
|
|
|
168
172
|
private
|
|
@@ -186,32 +190,38 @@ module CollectionSpace
|
|
|
186
190
|
@cache.exists?(key)
|
|
187
191
|
end
|
|
188
192
|
|
|
189
|
-
def
|
|
190
|
-
|
|
193
|
+
def set_backend(config)
|
|
194
|
+
if config.key?(:redis)
|
|
195
|
+
Backend::Redis.new(config[:redis])
|
|
196
|
+
elsif config.key?(:store)
|
|
197
|
+
Backend::ActivesupportCacheStore.new(config[:store])
|
|
198
|
+
else
|
|
199
|
+
Backend::Zache.new
|
|
200
|
+
end
|
|
191
201
|
end
|
|
192
202
|
|
|
193
203
|
def generate_key(parts = [])
|
|
194
204
|
Digest::SHA2.hexdigest(parts.dup.append(domain).join).prepend("refcache::")
|
|
195
205
|
end
|
|
196
206
|
|
|
197
|
-
def object_key(id)
|
|
198
|
-
generate_key(["collectionobjects", id])
|
|
207
|
+
def object_key(id, value_type = nil)
|
|
208
|
+
generate_key(["collectionobjects", id, value_type].compact)
|
|
199
209
|
end
|
|
200
210
|
|
|
201
|
-
def procedure_key(type, id)
|
|
202
|
-
generate_key([type, id])
|
|
211
|
+
def procedure_key(type, id, value_type = nil)
|
|
212
|
+
generate_key([type, id, value_type].compact)
|
|
203
213
|
end
|
|
204
214
|
|
|
205
|
-
def relation_key(reltype, subjectcsid, objectcsid)
|
|
206
|
-
generate_key([reltype, subjectcsid, objectcsid])
|
|
215
|
+
def relation_key(reltype, subjectcsid, objectcsid, value_type = nil)
|
|
216
|
+
generate_key([reltype, subjectcsid, objectcsid, value_type].compact)
|
|
207
217
|
end
|
|
208
218
|
|
|
209
|
-
def term_key(type, subtype, term)
|
|
210
|
-
generate_key([type, subtype, term])
|
|
219
|
+
def term_key(type, subtype, term, value_type = nil)
|
|
220
|
+
generate_key([type, subtype, term, value_type].compact)
|
|
211
221
|
end
|
|
212
222
|
|
|
213
|
-
def vocab_term_key(vocab, term)
|
|
214
|
-
generate_key(["vocabularies", vocab, term])
|
|
223
|
+
def vocab_term_key(vocab, term, value_type = nil)
|
|
224
|
+
generate_key(["vocabularies", vocab, term, value_type].compact)
|
|
215
225
|
end
|
|
216
226
|
end
|
|
217
227
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: collectionspace-refcache
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mark Cooper
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: redis
|
|
@@ -112,16 +111,16 @@ dependencies:
|
|
|
112
111
|
name: simplecov
|
|
113
112
|
requirement: !ruby/object:Gem::Requirement
|
|
114
113
|
requirements:
|
|
115
|
-
- - "
|
|
114
|
+
- - ">="
|
|
116
115
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: '0
|
|
116
|
+
version: '0'
|
|
118
117
|
type: :development
|
|
119
118
|
prerelease: false
|
|
120
119
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
120
|
requirements:
|
|
122
|
-
- - "
|
|
121
|
+
- - ">="
|
|
123
122
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: '0
|
|
123
|
+
version: '0'
|
|
125
124
|
- !ruby/object:Gem::Dependency
|
|
126
125
|
name: standard
|
|
127
126
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -162,6 +161,7 @@ files:
|
|
|
162
161
|
- doc/REFCACHE.md
|
|
163
162
|
- lib/collectionspace/refcache.rb
|
|
164
163
|
- lib/collectionspace/refcache/backend.rb
|
|
164
|
+
- lib/collectionspace/refcache/backend/activesupport_cache_store.rb
|
|
165
165
|
- lib/collectionspace/refcache/backend/redis.rb
|
|
166
166
|
- lib/collectionspace/refcache/backend/zache.rb
|
|
167
167
|
- lib/collectionspace/refcache/refcache.rb
|
|
@@ -172,7 +172,6 @@ licenses:
|
|
|
172
172
|
metadata:
|
|
173
173
|
homepage_uri: https://github.org/collectionspace/collectionspace-refcache
|
|
174
174
|
source_code_uri: https://github.org/collectionspace/collectionspace-refcache
|
|
175
|
-
post_install_message:
|
|
176
175
|
rdoc_options: []
|
|
177
176
|
require_paths:
|
|
178
177
|
- lib
|
|
@@ -180,15 +179,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
180
179
|
requirements:
|
|
181
180
|
- - ">="
|
|
182
181
|
- !ruby/object:Gem::Version
|
|
183
|
-
version:
|
|
182
|
+
version: 4.0.5
|
|
184
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
184
|
requirements:
|
|
186
185
|
- - ">="
|
|
187
186
|
- !ruby/object:Gem::Version
|
|
188
187
|
version: '0'
|
|
189
188
|
requirements: []
|
|
190
|
-
rubygems_version:
|
|
191
|
-
signing_key:
|
|
189
|
+
rubygems_version: 4.0.23
|
|
192
190
|
specification_version: 4
|
|
193
|
-
summary: CollectionSpace
|
|
191
|
+
summary: CollectionSpace Refcache.
|
|
194
192
|
test_files: []
|