any_cache 0.4.0 → 0.5.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/.rubocop.yml +1 -1
- data/.travis.yml +40 -16
- data/CHANGELOG.md +11 -0
- data/LICENSE.txt +1 -1
- data/README.md +23 -0
- data/any_cache.gemspec +2 -2
- data/gemfiles/active_support_with_redis.gemfile +1 -1
- data/gemfiles/redis.gemfile +1 -1
- data/gemfiles/redis_store.gemfile +1 -1
- data/lib/any_cache.rb +3 -0
- data/lib/any_cache/error.rb +6 -0
- data/lib/any_cache/plugins.rb +64 -0
- data/lib/any_cache/plugins/abstract.rb +13 -0
- data/lib/any_cache/plugins/interface_access_mixin.rb +26 -0
- data/lib/any_cache/plugins/registry.rb +125 -0
- data/lib/any_cache/version.rb +1 -1
- metadata +11 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b3bdf02896428164f98d1f75d08b0d2347e15987a7c98772bc7d81bae11eca49
|
|
4
|
+
data.tar.gz: a48891de0ae0ba1939a2fe6c806f419afbe504122274398032e0976517c927b4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 38f73611a43a1dd977a0b0b9056e15f58e7727f9b3b7d8607e6ac051b76ba97bbcc18d8d80085f933e56d4c843538d46d0d7d8beb0b60b39cadab3a04df262dc
|
|
7
|
+
data.tar.gz: 1e9474f4ce950aed89e7ef9bb84023bffd52318d0f706f22f92919c60ebd9141c2fe146e00e111c53f46f29a95973569d19c2b818b0c38b888f3480e65bcdfea
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
|
@@ -13,10 +13,13 @@ matrix:
|
|
|
13
13
|
- rvm: 2.3.8
|
|
14
14
|
gemfile: gemfiles/active_support.gemfile
|
|
15
15
|
env: TEST_AS_MEMORY_STORE_CACHE=true
|
|
16
|
-
- rvm: 2.4.
|
|
16
|
+
- rvm: 2.4.6
|
|
17
17
|
gemfile: gemfiles/active_support.gemfile
|
|
18
18
|
env: TEST_AS_MEMORY_STORE_CACHE=true
|
|
19
|
-
- rvm: 2.5.
|
|
19
|
+
- rvm: 2.5.5
|
|
20
|
+
gemfile: gemfiles/active_support.gemfile
|
|
21
|
+
env: TEST_AS_MEMORY_STORE_CACHE=true
|
|
22
|
+
- rvm: 2.6.3
|
|
20
23
|
gemfile: gemfiles/active_support.gemfile
|
|
21
24
|
env: TEST_AS_MEMORY_STORE_CACHE=true
|
|
22
25
|
- rvm: ruby-head
|
|
@@ -25,10 +28,13 @@ matrix:
|
|
|
25
28
|
- rvm: 2.3.8
|
|
26
29
|
gemfile: gemfiles/active_support.gemfile
|
|
27
30
|
env: TEST_AS_FILE_STORE_CACHE=true
|
|
28
|
-
- rvm: 2.4.
|
|
31
|
+
- rvm: 2.4.6
|
|
32
|
+
gemfile: gemfiles/active_support.gemfile
|
|
33
|
+
env: TEST_AS_FILE_STORE_CACHE=true
|
|
34
|
+
- rvm: 2.5.5
|
|
29
35
|
gemfile: gemfiles/active_support.gemfile
|
|
30
36
|
env: TEST_AS_FILE_STORE_CACHE=true
|
|
31
|
-
- rvm: 2.
|
|
37
|
+
- rvm: 2.6.3
|
|
32
38
|
gemfile: gemfiles/active_support.gemfile
|
|
33
39
|
env: TEST_AS_FILE_STORE_CACHE=true
|
|
34
40
|
- rvm: ruby-head
|
|
@@ -37,10 +43,13 @@ matrix:
|
|
|
37
43
|
- rvm: 2.3.8
|
|
38
44
|
gemfile: gemfiles/active_support_with_redis.gemfile
|
|
39
45
|
env: TEST_AS_REDIS_CACHE_STORE_CACHE=true
|
|
40
|
-
- rvm: 2.4.
|
|
46
|
+
- rvm: 2.4.6
|
|
41
47
|
gemfile: gemfiles/active_support_with_redis.gemfile
|
|
42
48
|
env: TEST_AS_REDIS_CACHE_STORE_CACHE=true
|
|
43
|
-
- rvm: 2.5.
|
|
49
|
+
- rvm: 2.5.5
|
|
50
|
+
gemfile: gemfiles/active_support_with_redis.gemfile
|
|
51
|
+
env: TEST_AS_REDIS_CACHE_STORE_CACHE=true
|
|
52
|
+
- rvm: 2.6.3
|
|
44
53
|
gemfile: gemfiles/active_support_with_redis.gemfile
|
|
45
54
|
env: TEST_AS_REDIS_CACHE_STORE_CACHE=true
|
|
46
55
|
- rvm: ruby-head
|
|
@@ -49,10 +58,13 @@ matrix:
|
|
|
49
58
|
- rvm: 2.3.8
|
|
50
59
|
gemfile: gemfiles/dalli.gemfile
|
|
51
60
|
env: TEST_DALLI_CACHE=true
|
|
52
|
-
- rvm: 2.4.
|
|
61
|
+
- rvm: 2.4.6
|
|
62
|
+
gemfile: gemfiles/dalli.gemfile
|
|
63
|
+
env: TEST_DALLI_CACHE=true
|
|
64
|
+
- rvm: 2.5.5
|
|
53
65
|
gemfile: gemfiles/dalli.gemfile
|
|
54
66
|
env: TEST_DALLI_CACHE=true
|
|
55
|
-
- rvm: 2.
|
|
67
|
+
- rvm: 2.6.3
|
|
56
68
|
gemfile: gemfiles/dalli.gemfile
|
|
57
69
|
env: TEST_DALLI_CACHE=true
|
|
58
70
|
- rvm: ruby-head
|
|
@@ -61,10 +73,13 @@ matrix:
|
|
|
61
73
|
- rvm: 2.3.8
|
|
62
74
|
gemfile: gemfiles/redis_store.gemfile
|
|
63
75
|
env: TEST_REDIS_STORE_CACHE=true
|
|
64
|
-
- rvm: 2.4.
|
|
76
|
+
- rvm: 2.4.6
|
|
65
77
|
gemfile: gemfiles/redis_store.gemfile
|
|
66
78
|
env: TEST_REDIS_STORE_CACHE=true
|
|
67
|
-
- rvm: 2.5.
|
|
79
|
+
- rvm: 2.5.5
|
|
80
|
+
gemfile: gemfiles/redis_store.gemfile
|
|
81
|
+
env: TEST_REDIS_STORE_CACHE=true
|
|
82
|
+
- rvm: 2.6.3
|
|
68
83
|
gemfile: gemfiles/redis_store.gemfile
|
|
69
84
|
env: TEST_REDIS_STORE_CACHE=true
|
|
70
85
|
- rvm: ruby-head
|
|
@@ -73,10 +88,13 @@ matrix:
|
|
|
73
88
|
- rvm: 2.3.8
|
|
74
89
|
gemfile: gemfiles/active_support_with_dalli.gemfile
|
|
75
90
|
env: TEST_AS_DALLI_STORE=true
|
|
76
|
-
- rvm: 2.4.
|
|
91
|
+
- rvm: 2.4.6
|
|
92
|
+
gemfile: gemfiles/active_support_with_dalli.gemfile
|
|
93
|
+
env: TEST_AS_DALLI_STORE=true
|
|
94
|
+
- rvm: 2.5.5
|
|
77
95
|
gemfile: gemfiles/active_support_with_dalli.gemfile
|
|
78
96
|
env: TEST_AS_DALLI_STORE=true
|
|
79
|
-
- rvm: 2.
|
|
97
|
+
- rvm: 2.6.3
|
|
80
98
|
gemfile: gemfiles/active_support_with_dalli.gemfile
|
|
81
99
|
env: TEST_AS_DALLI_STORE=true
|
|
82
100
|
- rvm: ruby-head
|
|
@@ -85,10 +103,13 @@ matrix:
|
|
|
85
103
|
- rvm: 2.3.8
|
|
86
104
|
gemfile: gemfiles/redis_store.gemfile
|
|
87
105
|
env: TEST_REDIS_CACHE=true
|
|
88
|
-
- rvm: 2.4.
|
|
106
|
+
- rvm: 2.4.6
|
|
89
107
|
gemfile: gemfiles/redis_store.gemfile
|
|
90
108
|
env: TEST_REDIS_CACHE=true
|
|
91
|
-
- rvm: 2.5.
|
|
109
|
+
- rvm: 2.5.5
|
|
110
|
+
gemfile: gemfiles/redis_store.gemfile
|
|
111
|
+
env: TEST_REDIS_CACHE=true
|
|
112
|
+
- rvm: 2.6.3
|
|
92
113
|
gemfile: gemfiles/redis_store.gemfile
|
|
93
114
|
env: TEST_REDIS_CACHE=true
|
|
94
115
|
- rvm: ruby-head
|
|
@@ -97,10 +118,13 @@ matrix:
|
|
|
97
118
|
- rvm: 2.3.8
|
|
98
119
|
gemfile: gemfiles/active_support_with_dalli.gemfile
|
|
99
120
|
env: TEST_AS_MEM_CACHE_STORE_CACHE=true
|
|
100
|
-
- rvm: 2.4.
|
|
121
|
+
- rvm: 2.4.6
|
|
122
|
+
gemfile: gemfiles/active_support_with_dalli.gemfile
|
|
123
|
+
env: TEST_AS_MEM_CACHE_STORE_CACHE=true
|
|
124
|
+
- rvm: 2.5.5
|
|
101
125
|
gemfile: gemfiles/active_support_with_dalli.gemfile
|
|
102
126
|
env: TEST_AS_MEM_CACHE_STORE_CACHE=true
|
|
103
|
-
- rvm: 2.
|
|
127
|
+
- rvm: 2.6.3
|
|
104
128
|
gemfile: gemfiles/active_support_with_dalli.gemfile
|
|
105
129
|
env: TEST_AS_MEM_CACHE_STORE_CACHE=true
|
|
106
130
|
- rvm: ruby-head
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## [0.5.0] - 2019-05-12
|
|
5
|
+
### Added
|
|
6
|
+
- Introduce Plugin Ecosystem (`AnyCache::Plugins`):
|
|
7
|
+
- load plugin: `AnyCache.plugin('plugin_name')` or `AnyCache.plugin(:plugin_name)`;
|
|
8
|
+
- get registered plugins: `AnyCache.plugins #=> array of strings`
|
|
9
|
+
- Support for last ruby versions (`ruby@2.6.3`, `ruby@2.4.6`, `ruby@2.5.5`)
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- Actualized dependencies (`qonfig` - `~> 0.10`);
|
|
13
|
+
- Actualized development dependencies;
|
|
14
|
+
|
|
4
15
|
## [0.4.0] - 2018-12-04
|
|
5
16
|
- `AnyCache#cleanup` - remove expired entries manually
|
|
6
17
|
(make sence only for `:as_file_store` and `:as_memory_store` at this moment);
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -14,6 +14,9 @@ Supported clients:
|
|
|
14
14
|
- `ActiveSupport::Cache::FileStore` ([gem activesupport](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/cache/file_store.rb)) ([file storage](https://api.rubyonrails.org/classes/ActiveSupport/Cache/FileStore.html))
|
|
15
15
|
- `ActiveSupport::Cache::MemoryStore` ([gem activesupport](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/cache/memory_store.rb)) ([in memory storage](https://api.rubyonrails.org/classes/ActiveSupport/Cache/MemoryStore.html))
|
|
16
16
|
|
|
17
|
+
- [Coming Soon] Simple in-memory hash-based cache client
|
|
18
|
+
- [Coming Soon] Simple key-value storage based on PostgreSQL
|
|
19
|
+
|
|
17
20
|
---
|
|
18
21
|
|
|
19
22
|
## Installation
|
|
@@ -61,6 +64,7 @@ require 'any_cache'
|
|
|
61
64
|
- [Existence](#existence)
|
|
62
65
|
- [Clear](#clear)
|
|
63
66
|
- [Cleanup](#cleanup)
|
|
67
|
+
- [Plugins](#plugins)
|
|
64
68
|
- [Roadmap](#roadmap)
|
|
65
69
|
|
|
66
70
|
---
|
|
@@ -335,6 +339,11 @@ end
|
|
|
335
339
|
AnyCache.configure do |conf|
|
|
336
340
|
conf.logger = AnyCache::Logging::Logger.new(STDOUT)
|
|
337
341
|
end
|
|
342
|
+
|
|
343
|
+
# --- (your cache client inherited from AnyCache) ---
|
|
344
|
+
YourCacheClient.configure do |conf|
|
|
345
|
+
# same configs as above
|
|
346
|
+
end
|
|
338
347
|
```
|
|
339
348
|
|
|
340
349
|
Log message format:
|
|
@@ -689,6 +698,20 @@ cache_store.cleanup # remove expired entries from database (release disk space f
|
|
|
689
698
|
|
|
690
699
|
---
|
|
691
700
|
|
|
701
|
+
## Plugins
|
|
702
|
+
|
|
703
|
+
`AnyCache` provides a set of plugins and an interface for controllable plugin registering and loading.
|
|
704
|
+
|
|
705
|
+
```ruby
|
|
706
|
+
# --- show names of registered plugins ---
|
|
707
|
+
AnyCache.plugins # => array of strings
|
|
708
|
+
|
|
709
|
+
# --- load specific plugin ---
|
|
710
|
+
AnyCache.plugin(:plugin_name) # or AnyCache.plugin('plugin_name')
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
---
|
|
714
|
+
|
|
692
715
|
## Build
|
|
693
716
|
|
|
694
717
|
- see [bin/rspec](bin/rspec)
|
data/any_cache.gemspec
CHANGED
|
@@ -28,11 +28,11 @@ Gem::Specification.new do |spec|
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
spec.add_dependency 'concurrent-ruby', '~> 1.0'
|
|
31
|
-
spec.add_dependency 'qonfig', '~> 0.
|
|
31
|
+
spec.add_dependency 'qonfig', '~> 0.10'
|
|
32
32
|
|
|
33
33
|
spec.add_development_dependency 'coveralls', '~> 0.8'
|
|
34
34
|
spec.add_development_dependency 'simplecov', '~> 0.16'
|
|
35
|
-
spec.add_development_dependency 'armitage-rubocop', '~> 0.
|
|
35
|
+
spec.add_development_dependency 'armitage-rubocop', '~> 0.29'
|
|
36
36
|
spec.add_development_dependency 'rspec', '~> 3.8'
|
|
37
37
|
|
|
38
38
|
spec.add_development_dependency 'bundler'
|
data/gemfiles/redis.gemfile
CHANGED
data/lib/any_cache.rb
CHANGED
|
@@ -16,6 +16,7 @@ class AnyCache
|
|
|
16
16
|
require_relative 'any_cache/logging'
|
|
17
17
|
require_relative 'any_cache/delegation'
|
|
18
18
|
require_relative 'any_cache/patches'
|
|
19
|
+
require_relative 'any_cache/plugins'
|
|
19
20
|
|
|
20
21
|
# @since 0.2.0
|
|
21
22
|
include Qonfig::Configurable
|
|
@@ -23,6 +24,8 @@ class AnyCache
|
|
|
23
24
|
include Delegation
|
|
24
25
|
# @since 0.3.1
|
|
25
26
|
extend Patches::InterfaceAccessMixin
|
|
27
|
+
# @since 0.5.0
|
|
28
|
+
extend Plugins::InterfaceAccessMixin
|
|
26
29
|
|
|
27
30
|
# @since 0.2.0
|
|
28
31
|
# rubocop:disable Metrics/BlockLength
|
data/lib/any_cache/error.rb
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# @api public
|
|
4
|
+
# @since 0.5.0
|
|
5
|
+
module AnyCache::Plugins
|
|
6
|
+
require_relative 'plugins/abstract'
|
|
7
|
+
require_relative 'plugins/registry'
|
|
8
|
+
require_relative 'plugins/interface_access_mixin'
|
|
9
|
+
|
|
10
|
+
# @since 0.5.0
|
|
11
|
+
@plugin_registry = Registry.new
|
|
12
|
+
# @since 0.5.0
|
|
13
|
+
@access_lock = Mutex.new
|
|
14
|
+
|
|
15
|
+
class << self
|
|
16
|
+
# @param plugin_name [Symbol, String]
|
|
17
|
+
# @return [void]
|
|
18
|
+
#
|
|
19
|
+
# @api public
|
|
20
|
+
# @since 0.5.0
|
|
21
|
+
def load(plugin_name)
|
|
22
|
+
thread_safe { plugin_registry[plugin_name].load! }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @return [Array<String>]
|
|
26
|
+
#
|
|
27
|
+
# @api public
|
|
28
|
+
# @since 0.5.0
|
|
29
|
+
def names
|
|
30
|
+
thread_safe { plugin_registry.names }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# @param plugin_name [Symbol, String]
|
|
34
|
+
# @return [void]
|
|
35
|
+
#
|
|
36
|
+
# @api private
|
|
37
|
+
# @since 0.5.0
|
|
38
|
+
def register(plugin_name, plugin_module)
|
|
39
|
+
thread_safe { plugin_registry[plugin_name] = plugin_module }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
# @return [AnyCache::Plugins::Registry]
|
|
45
|
+
#
|
|
46
|
+
# @api private
|
|
47
|
+
# @since 0.5.0
|
|
48
|
+
attr_reader :plugin_registry
|
|
49
|
+
|
|
50
|
+
# @return [Mutex]
|
|
51
|
+
#
|
|
52
|
+
# @api private
|
|
53
|
+
# @since 0.5.0
|
|
54
|
+
attr_reader :access_lock
|
|
55
|
+
|
|
56
|
+
# @return [void]
|
|
57
|
+
#
|
|
58
|
+
# @api private
|
|
59
|
+
# @since 0.5.0
|
|
60
|
+
def thread_safe
|
|
61
|
+
access_lock.synchronize { yield if block_given? }
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# @api private
|
|
4
|
+
# @since 0.5.0
|
|
5
|
+
module AnyCache::Plugins::InterfaceAccessMixin
|
|
6
|
+
# @param plugin_name [Symbol, String]
|
|
7
|
+
# @return [void]
|
|
8
|
+
#
|
|
9
|
+
# @see AnyCache::Plugins
|
|
10
|
+
#
|
|
11
|
+
# @api public
|
|
12
|
+
# @since 0.5.0
|
|
13
|
+
def plugin(plugin_name)
|
|
14
|
+
AnyCache::Plugins.load(plugin_name)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# @return [Array<String>]
|
|
18
|
+
#
|
|
19
|
+
# @see AnyCache::Plugins
|
|
20
|
+
#
|
|
21
|
+
# @api public
|
|
22
|
+
# @since 0.5.0
|
|
23
|
+
def plugins
|
|
24
|
+
AnyCache::Plugins.names
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# @api private
|
|
4
|
+
# @since 0.5.0
|
|
5
|
+
class AnyCache::Plugins::Registry
|
|
6
|
+
# @return [void]
|
|
7
|
+
#
|
|
8
|
+
# @api private
|
|
9
|
+
# @since 0.5.0
|
|
10
|
+
def initialize
|
|
11
|
+
@plugin_set = {}
|
|
12
|
+
@access_lock = Mutex.new
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @param plugin_name [Symbol, String]
|
|
16
|
+
# @return [AnyCache::Plugins::Abstract]
|
|
17
|
+
#
|
|
18
|
+
# @api private
|
|
19
|
+
# @since 0.5.0
|
|
20
|
+
def [](plugin_name)
|
|
21
|
+
thread_safe { fetch(plugin_name) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @param plugin_name [Symbol, String]
|
|
25
|
+
# @param plugin_module [AnyCache::Plugins::Abstract]
|
|
26
|
+
# @return [void]
|
|
27
|
+
#
|
|
28
|
+
# @api private
|
|
29
|
+
# @since 0.5.0
|
|
30
|
+
def register(plugin_name, plugin_module)
|
|
31
|
+
thread_safe { apply(plugin_name, plugin_module) }
|
|
32
|
+
end
|
|
33
|
+
alias_method :[]=, :register
|
|
34
|
+
|
|
35
|
+
# @return [Array<String>]
|
|
36
|
+
#
|
|
37
|
+
# @api private
|
|
38
|
+
# @since 0.5.0
|
|
39
|
+
def names
|
|
40
|
+
thread_safe { plugin_names }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
# @return [Hash]
|
|
46
|
+
#
|
|
47
|
+
# @api private
|
|
48
|
+
# @since 0.5.0
|
|
49
|
+
attr_reader :plugin_set
|
|
50
|
+
|
|
51
|
+
# @return [Mutex]
|
|
52
|
+
#
|
|
53
|
+
# @api private
|
|
54
|
+
# @since 0.5.0
|
|
55
|
+
attr_reader :access_lock
|
|
56
|
+
|
|
57
|
+
# @return [void]
|
|
58
|
+
#
|
|
59
|
+
# @api private
|
|
60
|
+
# @since 0.5.0
|
|
61
|
+
def thread_safe
|
|
62
|
+
access_lock.synchronize { yield if block_given? }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# @return [Array<String>]
|
|
66
|
+
#
|
|
67
|
+
# @api private
|
|
68
|
+
# @since 0.5.0
|
|
69
|
+
def plugin_names
|
|
70
|
+
plugin_set.keys
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# @param plugin_name [String]
|
|
74
|
+
# @return [Boolean]
|
|
75
|
+
#
|
|
76
|
+
# @api private
|
|
77
|
+
# @since 0.5.0
|
|
78
|
+
def registered?(plugin_name)
|
|
79
|
+
plugin_set.key?(plugin_name)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# @param plugin_name [Symbol, String]
|
|
83
|
+
# @param plugin_module [AnyCache::Plugins::Abstract]
|
|
84
|
+
# @return [void]
|
|
85
|
+
#
|
|
86
|
+
# @raise [AnyCache::AlreadyRegisteredPluginError]
|
|
87
|
+
#
|
|
88
|
+
# @api private
|
|
89
|
+
# @since 0.5.0
|
|
90
|
+
def apply(plugin_name, plugin_module)
|
|
91
|
+
plugin_name = indifferently_accessable_plugin_name(plugin_name)
|
|
92
|
+
|
|
93
|
+
if registered?(plugin_name)
|
|
94
|
+
raise AnyCache::AlreadyRegisteredPluginError, "#{plugin_name} plugin already exist"
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
plugin_set[plugin_name] = plugin_module
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# @param plugin_name [Symbol, String]
|
|
101
|
+
# @return [AnyCache::Plugins::Abstract]
|
|
102
|
+
#
|
|
103
|
+
# @raise [AnyCache::UnregisteredPluginError]
|
|
104
|
+
#
|
|
105
|
+
# @api private
|
|
106
|
+
# @since 0.5.0
|
|
107
|
+
def fetch(plugin_name)
|
|
108
|
+
plugin_name = indifferently_accessable_plugin_name(plugin_name)
|
|
109
|
+
|
|
110
|
+
unless registered?(plugin_name)
|
|
111
|
+
raise AnyCache::UnregisteredPluginError, "#{plugin_name} plugin is not registered"
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
plugin_set[plugin_name]
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# @param key [Symbol, String]
|
|
118
|
+
# @return [String]
|
|
119
|
+
#
|
|
120
|
+
# @api private
|
|
121
|
+
# @since 0.5.0
|
|
122
|
+
def indifferently_accessable_plugin_name(plugin_name)
|
|
123
|
+
plugin_name.to_s
|
|
124
|
+
end
|
|
125
|
+
end
|
data/lib/any_cache/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: any_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
|
- Rustam Ibragimov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-05-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0.
|
|
33
|
+
version: '0.10'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0.
|
|
40
|
+
version: '0.10'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: coveralls
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -72,14 +72,14 @@ dependencies:
|
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '0.
|
|
75
|
+
version: '0.29'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '0.
|
|
82
|
+
version: '0.29'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: rspec
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -213,6 +213,10 @@ files:
|
|
|
213
213
|
- lib/any_cache/logging/logger.rb
|
|
214
214
|
- lib/any_cache/patches.rb
|
|
215
215
|
- lib/any_cache/patches/dalli_store.rb
|
|
216
|
+
- lib/any_cache/plugins.rb
|
|
217
|
+
- lib/any_cache/plugins/abstract.rb
|
|
218
|
+
- lib/any_cache/plugins/interface_access_mixin.rb
|
|
219
|
+
- lib/any_cache/plugins/registry.rb
|
|
216
220
|
- lib/any_cache/version.rb
|
|
217
221
|
homepage: https://github.com/0exp/any_cache
|
|
218
222
|
licenses:
|
|
@@ -233,8 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
233
237
|
- !ruby/object:Gem::Version
|
|
234
238
|
version: '0'
|
|
235
239
|
requirements: []
|
|
236
|
-
|
|
237
|
-
rubygems_version: 2.7.6
|
|
240
|
+
rubygems_version: 3.0.2
|
|
238
241
|
signing_key:
|
|
239
242
|
specification_version: 4
|
|
240
243
|
summary: AnyCache - a simplest cache wrapper
|