evt-entity_cache 0.18.2.2 → 2.0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/entity_cache.rb +2 -0
- data/lib/entity_cache/controls.rb +4 -0
- data/lib/entity_cache/controls/entity_cache.rb +11 -0
- data/lib/entity_cache/controls/record.rb +1 -1
- data/lib/entity_cache/controls/specifier.rb +16 -0
- data/lib/entity_cache/controls/store/external.rb +4 -2
- data/lib/entity_cache/controls/store/external/example.rb +3 -1
- data/lib/entity_cache/controls/subject.rb +28 -2
- data/lib/entity_cache/entity_cache.rb +19 -3
- data/lib/entity_cache/store/external.rb +8 -0
- data/lib/entity_cache/subject.rb +29 -0
- data/lib/entity_cache/substitute.rb +3 -0
- metadata +9 -8
- data/lib/loader.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcdf7aa3489308ed84b73822573806208b675aa88a696234b8a883c0eda03cc2
|
4
|
+
data.tar.gz: 04c895524f043e2092a4853a478ebfb61ba73de99f616fe564e975a0d36d1623
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c54ed18483b733b23872f2237f6d694e6b9e7dc373b602a08b9166f827e48a0b29983f4c5c25aa9c52bd9098798138b3fcca22b32eee2924698727b751fbe541
|
7
|
+
data.tar.gz: e017489372a170d34d6d616daffa67a736847e537b425730a36c7601fa753dd3117ee3e580efb3d54ae7999efa8b09fc6ccb42aa618cdb8a86398533591cd5fe
|
data/lib/entity_cache.rb
CHANGED
@@ -11,6 +11,8 @@ require 'entity_cache/controls/subject'
|
|
11
11
|
require 'entity_cache/controls/time'
|
12
12
|
require 'entity_cache/controls/version'
|
13
13
|
|
14
|
+
require 'entity_cache/controls/specifier'
|
15
|
+
|
14
16
|
require 'entity_cache/controls/persist_interval'
|
15
17
|
|
16
18
|
require 'entity_cache/controls/store/external'
|
@@ -19,3 +21,5 @@ require 'entity_cache/controls/store/external/not_implemented'
|
|
19
21
|
require 'entity_cache/controls/store/external/write'
|
20
22
|
|
21
23
|
require 'entity_cache/controls/store/internal'
|
24
|
+
|
25
|
+
require 'entity_cache/controls/entity_cache'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class EntityCache
|
2
|
+
module Controls
|
3
|
+
module EntityCache
|
4
|
+
def self.example(subject=nil, entity_class: nil, specifier: nil, random_specifier: nil)
|
5
|
+
subject ||= Subject.example(entity_class: entity_class, specifier: specifier, random: random_specifier)
|
6
|
+
|
7
|
+
::EntityCache.new(subject)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class EntityCache
|
2
|
+
module Controls
|
3
|
+
module Specifier
|
4
|
+
def self.example(specifier: nil, random: nil)
|
5
|
+
specifier ||= 'SomeSpecifier'
|
6
|
+
random ||= false
|
7
|
+
|
8
|
+
if random
|
9
|
+
specifier = "#{specifier}#{SecureRandom.hex(8)}"
|
10
|
+
end
|
11
|
+
|
12
|
+
specifier
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -2,8 +2,10 @@ class EntityCache
|
|
2
2
|
module Controls
|
3
3
|
module Store
|
4
4
|
module External
|
5
|
-
def self.example(subject=nil)
|
6
|
-
|
5
|
+
def self.example(subject=nil, entity_class: nil, specifier: nil, random: nil)
|
6
|
+
random = true if random.nil?
|
7
|
+
|
8
|
+
subject ||= Subject.example(random: random, entity_class: entity_class, specifier: specifier)
|
7
9
|
|
8
10
|
Example.build(subject)
|
9
11
|
end
|
@@ -1,8 +1,34 @@
|
|
1
1
|
class EntityCache
|
2
2
|
module Controls
|
3
3
|
module Subject
|
4
|
-
def self.example
|
5
|
-
|
4
|
+
def self.example(entity_class: nil, specifier: nil, random: nil)
|
5
|
+
entity_class ||= self.entity_class
|
6
|
+
|
7
|
+
if specifier == :none
|
8
|
+
specifier = nil
|
9
|
+
else
|
10
|
+
specifier = Specifier.example(specifier: specifier, random: random)
|
11
|
+
end
|
12
|
+
|
13
|
+
::EntityCache::Subject.build({
|
14
|
+
:entity_class => entity_class,
|
15
|
+
:specifier => specifier
|
16
|
+
})
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.entity_class
|
20
|
+
Entity::Example
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.specifier
|
24
|
+
Specifier.example
|
25
|
+
end
|
26
|
+
|
27
|
+
module HashKey
|
28
|
+
def self.example(**args)
|
29
|
+
subject = Subject.example(**args)
|
30
|
+
subject.hash_key
|
31
|
+
end
|
6
32
|
end
|
7
33
|
end
|
8
34
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
class EntityCache
|
2
2
|
include Configure
|
3
3
|
include Dependency
|
4
|
+
include Initializer
|
4
5
|
include Log::Dependency
|
5
6
|
|
6
7
|
configure :entity_cache
|
@@ -10,12 +11,27 @@ class EntityCache
|
|
10
11
|
@persist_interval ||= Defaults.persist_interval
|
11
12
|
end
|
12
13
|
|
14
|
+
def entity_class
|
15
|
+
subject.entity_class
|
16
|
+
end
|
17
|
+
|
18
|
+
def specifier
|
19
|
+
subject.specifier
|
20
|
+
end
|
21
|
+
|
13
22
|
dependency :clock, Clock::UTC
|
14
23
|
dependency :internal_store, Store::Internal
|
15
24
|
dependency :external_store, Store::External
|
16
25
|
|
17
|
-
|
18
|
-
|
26
|
+
initializer :subject
|
27
|
+
|
28
|
+
def self.build(entity_class, specifier=nil, scope: nil, persist_interval: nil, external_store: nil, external_store_session: nil)
|
29
|
+
subject = Subject.build({
|
30
|
+
:entity_class => entity_class,
|
31
|
+
:specifier => specifier
|
32
|
+
})
|
33
|
+
|
34
|
+
instance = new(subject)
|
19
35
|
|
20
36
|
instance.configure(
|
21
37
|
subject: subject,
|
@@ -54,7 +70,7 @@ class EntityCache
|
|
54
70
|
if record.nil?
|
55
71
|
logger.info(tags: [:get, :miss]) { "Cache miss getting entity (ID: #{id.inspect}, #{Record::LogText.get(record)})" }
|
56
72
|
else
|
57
|
-
logger.info(
|
73
|
+
logger.info(tags: [:get, :hit]) { "Get entity done (ID: #{id.inspect}, #{Record::LogText.get(record)})" }
|
58
74
|
end
|
59
75
|
|
60
76
|
record
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class EntityCache
|
2
|
+
class Subject
|
3
|
+
include Schema::DataStructure
|
4
|
+
|
5
|
+
attribute :entity_class, Class
|
6
|
+
attribute :specifier, String
|
7
|
+
|
8
|
+
def hash_key
|
9
|
+
self.class.hash_key(entity_class, specifier)
|
10
|
+
end
|
11
|
+
alias_method :to_s, :hash_key
|
12
|
+
|
13
|
+
def hash
|
14
|
+
hash_key.hash
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.hash_key(entity_class, specifier=nil)
|
18
|
+
if specifier.nil?
|
19
|
+
"#{entity_class}"
|
20
|
+
else
|
21
|
+
"#{entity_class}#{hash_key_separator}#{specifier}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.hash_key_separator
|
26
|
+
'/'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-entity_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 2.0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-configure
|
@@ -89,9 +89,11 @@ files:
|
|
89
89
|
- lib/entity_cache.rb
|
90
90
|
- lib/entity_cache/controls.rb
|
91
91
|
- lib/entity_cache/controls/entity.rb
|
92
|
+
- lib/entity_cache/controls/entity_cache.rb
|
92
93
|
- lib/entity_cache/controls/id.rb
|
93
94
|
- lib/entity_cache/controls/persist_interval.rb
|
94
95
|
- lib/entity_cache/controls/record.rb
|
96
|
+
- lib/entity_cache/controls/specifier.rb
|
95
97
|
- lib/entity_cache/controls/store/external.rb
|
96
98
|
- lib/entity_cache/controls/store/external/example.rb
|
97
99
|
- lib/entity_cache/controls/store/external/not_implemented.rb
|
@@ -118,13 +120,13 @@ files:
|
|
118
120
|
- lib/entity_cache/store/internal/scope/global.rb
|
119
121
|
- lib/entity_cache/store/internal/scope/thread.rb
|
120
122
|
- lib/entity_cache/store/internal/substitute.rb
|
123
|
+
- lib/entity_cache/subject.rb
|
121
124
|
- lib/entity_cache/substitute.rb
|
122
|
-
- lib/loader.rb
|
123
125
|
homepage: https://github.com/eventide-project/entity-cache
|
124
126
|
licenses:
|
125
127
|
- MIT
|
126
128
|
metadata: {}
|
127
|
-
post_install_message:
|
129
|
+
post_install_message:
|
128
130
|
rdoc_options: []
|
129
131
|
require_paths:
|
130
132
|
- lib
|
@@ -139,9 +141,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
141
|
- !ruby/object:Gem::Version
|
140
142
|
version: '0'
|
141
143
|
requirements: []
|
142
|
-
|
143
|
-
|
144
|
-
signing_key:
|
144
|
+
rubygems_version: 3.1.2
|
145
|
+
signing_key:
|
145
146
|
specification_version: 4
|
146
147
|
summary: Cache of entities retrieved by an entity-store, with in-memory temporary
|
147
148
|
and on-disk permanent storage options
|
data/lib/loader.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
lib/entity_cache.rb
|