evt-entity_cache 0.14.0.1 → 0.15.0.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/controls/{storage/persistent → store/external}/example.rb +4 -4
- data/lib/entity_cache/controls/{storage/persistent → store/external}/not_implemented.rb +3 -3
- data/lib/entity_cache/controls/{storage/persistent → store/external}/write.rb +3 -3
- data/lib/entity_cache/controls/{storage/persistent.rb → store/external.rb} +2 -2
- data/lib/entity_cache/controls/{storage/temporary.rb → store/internal.rb} +3 -3
- data/lib/entity_cache/controls.rb +5 -5
- data/lib/entity_cache/entity_cache.rb +17 -17
- data/lib/entity_cache/store/{persistent → external}/null.rb +2 -2
- data/lib/entity_cache/store/{persistent → external}/substitute.rb +4 -4
- data/lib/entity_cache/store/{persistent → external}/telemetry.rb +1 -1
- data/lib/entity_cache/store/{persistent.rb → external.rb} +4 -4
- data/lib/entity_cache/store/{temporary → internal}/build/defaults.rb +1 -1
- data/lib/entity_cache/store/{temporary → internal}/build.rb +1 -1
- data/lib/entity_cache/store/{temporary → internal}/scope/exclusive.rb +2 -2
- data/lib/entity_cache/store/{temporary → internal}/scope/global.rb +2 -2
- data/lib/entity_cache/store/{temporary → internal}/scope/thread.rb +2 -2
- data/lib/entity_cache/store/{temporary → internal}/substitute.rb +3 -3
- data/lib/entity_cache/store/{temporary.rb → internal.rb} +2 -2
- data/lib/entity_cache/substitute.rb +1 -1
- data/lib/entity_cache.rb +11 -11
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b5634a6a1309c38882809b0e2e30de97aa97025
|
4
|
+
data.tar.gz: f66490edd1a241eb54567dc15dc5b3bf1236f74e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba632a148922b525980f03f698bd5b4bb7684229fd948838d53ab4a4b711bd40ecaa92f65751ae78cec7d5db696a18b56e45a1ab298f4e7071254df7c8016447
|
7
|
+
data.tar.gz: 6c7549ac4a7eff2202a4d4a87d716f2556f0ebd415fb8e43be0545a11b88d4a0080ec1b1aeb9f0868c6b33a531125663690761385b534db5d0163d1bdd393b5e
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class EntityCache
|
2
2
|
module Controls
|
3
|
-
module
|
4
|
-
module
|
3
|
+
module Store
|
4
|
+
module External
|
5
5
|
class Example
|
6
|
-
include EntityCache::Store::
|
6
|
+
include EntityCache::Store::External
|
7
7
|
|
8
8
|
attr_accessor :session
|
9
9
|
|
@@ -32,7 +32,7 @@ class EntityCache
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def path(id)
|
35
|
-
|
35
|
+
External.path(subject, id)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class EntityCache
|
2
2
|
module Controls
|
3
|
-
module
|
4
|
-
module
|
3
|
+
module Store
|
4
|
+
module External
|
5
5
|
module NotImplemented
|
6
6
|
def self.example
|
7
7
|
subject = Subject.example
|
@@ -10,7 +10,7 @@ class EntityCache
|
|
10
10
|
end
|
11
11
|
|
12
12
|
class Example
|
13
|
-
include EntityCache::Store::
|
13
|
+
include EntityCache::Store::External
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class EntityCache
|
2
2
|
module Controls
|
3
|
-
module
|
4
|
-
module
|
3
|
+
module Store
|
4
|
+
module External
|
5
5
|
module Write
|
6
6
|
def self.call
|
7
7
|
subject = Subject.example
|
@@ -12,7 +12,7 @@ class EntityCache
|
|
12
12
|
Controls::Record.persisted_time
|
13
13
|
])
|
14
14
|
|
15
|
-
path =
|
15
|
+
path = External.path(subject)
|
16
16
|
|
17
17
|
File.write(path, text)
|
18
18
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class EntityCache
|
2
2
|
module Controls
|
3
|
-
module
|
4
|
-
module
|
3
|
+
module Store
|
4
|
+
module Internal
|
5
5
|
def self.example
|
6
6
|
Example.new
|
7
7
|
end
|
8
8
|
|
9
|
-
class Example < EntityCache::Store::
|
9
|
+
class Example < EntityCache::Store::Internal
|
10
10
|
def records
|
11
11
|
@records ||= {}
|
12
12
|
end
|
@@ -13,9 +13,9 @@ require 'entity_cache/controls/version'
|
|
13
13
|
|
14
14
|
require 'entity_cache/controls/persist_interval'
|
15
15
|
|
16
|
-
require 'entity_cache/controls/
|
17
|
-
require 'entity_cache/controls/
|
18
|
-
require 'entity_cache/controls/
|
19
|
-
require 'entity_cache/controls/
|
16
|
+
require 'entity_cache/controls/store/external'
|
17
|
+
require 'entity_cache/controls/store/external/example'
|
18
|
+
require 'entity_cache/controls/store/external/not_implemented'
|
19
|
+
require 'entity_cache/controls/store/external/write'
|
20
20
|
|
21
|
-
require 'entity_cache/controls/
|
21
|
+
require 'entity_cache/controls/store/internal'
|
@@ -9,33 +9,33 @@ class EntityCache
|
|
9
9
|
end
|
10
10
|
|
11
11
|
dependency :clock, Clock::UTC
|
12
|
-
dependency :
|
13
|
-
dependency :
|
12
|
+
dependency :internal_store, Store::Internal
|
13
|
+
dependency :external_store, Store::External
|
14
14
|
|
15
|
-
def self.build(subject, scope: nil, persist_interval: nil,
|
15
|
+
def self.build(subject, scope: nil, persist_interval: nil, external_store: nil, external_store_session: nil)
|
16
16
|
instance = new
|
17
17
|
|
18
18
|
instance.configure(
|
19
19
|
subject: subject,
|
20
20
|
scope: scope,
|
21
21
|
persist_interval: persist_interval,
|
22
|
-
|
23
|
-
|
22
|
+
external_store: external_store,
|
23
|
+
external_store_session: external_store_session
|
24
24
|
)
|
25
25
|
|
26
26
|
instance
|
27
27
|
end
|
28
28
|
|
29
|
-
def configure(subject:, scope: nil, persist_interval: nil,
|
30
|
-
|
29
|
+
def configure(subject:, scope: nil, persist_interval: nil, external_store: nil, external_store_session: nil)
|
30
|
+
external_store ||= Store::External::Null
|
31
31
|
|
32
32
|
unless persist_interval.nil?
|
33
33
|
self.persist_interval = persist_interval
|
34
34
|
end
|
35
35
|
|
36
|
-
Store::
|
36
|
+
Store::Internal.configure(self, subject, scope: scope)
|
37
37
|
|
38
|
-
|
38
|
+
external_store.configure(self, subject, session: external_store_session)
|
39
39
|
|
40
40
|
Clock::UTC.configure(self)
|
41
41
|
end
|
@@ -43,7 +43,7 @@ class EntityCache
|
|
43
43
|
def get(id)
|
44
44
|
logger.trace { "Get entity (ID: #{id.inspect})" }
|
45
45
|
|
46
|
-
record =
|
46
|
+
record = internal_store.get(id)
|
47
47
|
|
48
48
|
if record.nil?
|
49
49
|
record = restore(id)
|
@@ -61,26 +61,26 @@ class EntityCache
|
|
61
61
|
def put(id, entity, version, time: nil, persisted_version: nil, persisted_time: nil)
|
62
62
|
time ||= clock.now
|
63
63
|
|
64
|
-
|
64
|
+
updated_external_store = false
|
65
65
|
|
66
66
|
record = Record.build(id, entity, version, time)
|
67
67
|
|
68
68
|
logger.trace { "Put entity (ID: #{id.inspect}, #{Record::LogText.get(record)}, Persist Interval: #{persist_interval.inspect})" }
|
69
69
|
|
70
70
|
if persist?(version, persisted_version)
|
71
|
-
|
71
|
+
external_store.put(id, entity, version, time)
|
72
72
|
|
73
73
|
persisted_version = version
|
74
74
|
persisted_time = time
|
75
|
-
|
75
|
+
updated_external_store = true
|
76
76
|
end
|
77
77
|
|
78
78
|
record.persisted_version = persisted_version
|
79
79
|
record.persisted_time = persisted_time
|
80
80
|
|
81
|
-
|
81
|
+
internal_store.put(record)
|
82
82
|
|
83
|
-
logger.info { "Put entity done (ID: #{id.inspect}, #{Record::LogText.get(record)}, Persist Interval: #{persist_interval.inspect}, Updated
|
83
|
+
logger.info { "Put entity done (ID: #{id.inspect}, #{Record::LogText.get(record)}, Persist Interval: #{persist_interval.inspect}, Updated External Store: #{updated_external_store})" }
|
84
84
|
|
85
85
|
record
|
86
86
|
end
|
@@ -88,7 +88,7 @@ class EntityCache
|
|
88
88
|
def restore(id)
|
89
89
|
logger.trace { "Restoring entity (ID: #{id.inspect})" }
|
90
90
|
|
91
|
-
entity, version, time =
|
91
|
+
entity, version, time = external_store.get(id)
|
92
92
|
|
93
93
|
if entity.nil?
|
94
94
|
logger.debug { "Could not restore entity (ID: #{id.inspect})" }
|
@@ -105,7 +105,7 @@ class EntityCache
|
|
105
105
|
persisted_time: time
|
106
106
|
)
|
107
107
|
|
108
|
-
|
108
|
+
internal_store.put(record)
|
109
109
|
|
110
110
|
logger.debug { "Restored entity (ID: #{id.inspect}, #{Record::LogText.get(record)})" }
|
111
111
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
class EntityCache
|
2
2
|
module Store
|
3
|
-
module
|
3
|
+
module External
|
4
4
|
module Substitute
|
5
5
|
def self.build
|
6
|
-
|
6
|
+
External.build
|
7
7
|
end
|
8
8
|
|
9
|
-
class
|
10
|
-
include Store::
|
9
|
+
class External
|
10
|
+
include Store::External
|
11
11
|
|
12
12
|
attr_accessor :telemetry_sink
|
13
13
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class EntityCache
|
2
2
|
module Store
|
3
|
-
module
|
3
|
+
module External
|
4
4
|
def self.included(cls)
|
5
5
|
cls.class_exec do
|
6
6
|
include Log::Dependency
|
@@ -8,7 +8,7 @@ class EntityCache
|
|
8
8
|
extend Build
|
9
9
|
extend RegisterTelemetrySink
|
10
10
|
|
11
|
-
configure :
|
11
|
+
configure :external_store
|
12
12
|
|
13
13
|
dependency :telemetry, ::Telemetry
|
14
14
|
|
@@ -69,9 +69,9 @@ class EntityCache
|
|
69
69
|
end
|
70
70
|
|
71
71
|
module RegisterTelemetrySink
|
72
|
-
def register_telemetry_sink(
|
72
|
+
def register_telemetry_sink(external_store)
|
73
73
|
sink = Telemetry::Sink.new
|
74
|
-
|
74
|
+
external_store.telemetry.register(sink)
|
75
75
|
sink
|
76
76
|
end
|
77
77
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class EntityCache
|
2
2
|
module Store
|
3
|
-
class
|
3
|
+
class Internal
|
4
4
|
module Substitute
|
5
5
|
def self.build
|
6
|
-
|
6
|
+
Internal.new
|
7
7
|
end
|
8
8
|
|
9
|
-
class
|
9
|
+
class Internal < Scope::Exclusive
|
10
10
|
def add(id, entity, version, time, persisted_version: nil, persisted_time: nil)
|
11
11
|
record = Record.build(
|
12
12
|
id,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class EntityCache
|
2
2
|
module Store
|
3
|
-
class
|
3
|
+
class Internal
|
4
4
|
include Log::Dependency
|
5
5
|
|
6
6
|
attr_accessor :subject
|
@@ -12,7 +12,7 @@ class EntityCache
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.configure(receiver, subject, scope: nil, attr_name: nil)
|
15
|
-
attr_name ||= :
|
15
|
+
attr_name ||= :internal_store
|
16
16
|
|
17
17
|
instance = Build.(subject, scope: scope)
|
18
18
|
receiver.public_send("#{attr_name}=", instance)
|
data/lib/entity_cache.rb
CHANGED
@@ -12,18 +12,18 @@ require 'entity_cache/record/destructure'
|
|
12
12
|
require 'entity_cache/record/log_text'
|
13
13
|
require 'entity_cache/record/transformer'
|
14
14
|
|
15
|
-
require 'entity_cache/store/
|
16
|
-
require 'entity_cache/store/
|
17
|
-
require 'entity_cache/store/
|
18
|
-
require 'entity_cache/store/
|
15
|
+
require 'entity_cache/store/external'
|
16
|
+
require 'entity_cache/store/external/null'
|
17
|
+
require 'entity_cache/store/external/substitute'
|
18
|
+
require 'entity_cache/store/external/telemetry'
|
19
19
|
|
20
|
-
require 'entity_cache/store/
|
21
|
-
require 'entity_cache/store/
|
22
|
-
require 'entity_cache/store/
|
23
|
-
require 'entity_cache/store/
|
24
|
-
require 'entity_cache/store/
|
25
|
-
require 'entity_cache/store/
|
26
|
-
require 'entity_cache/store/
|
20
|
+
require 'entity_cache/store/internal'
|
21
|
+
require 'entity_cache/store/internal/build'
|
22
|
+
require 'entity_cache/store/internal/build/defaults'
|
23
|
+
require 'entity_cache/store/internal/scope/exclusive'
|
24
|
+
require 'entity_cache/store/internal/scope/global'
|
25
|
+
require 'entity_cache/store/internal/scope/thread'
|
26
|
+
require 'entity_cache/store/internal/substitute'
|
27
27
|
|
28
28
|
require 'entity_cache/entity_cache'
|
29
29
|
require 'entity_cache/substitute'
|
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: 0.15.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-configure
|
@@ -92,11 +92,11 @@ files:
|
|
92
92
|
- lib/entity_cache/controls/id.rb
|
93
93
|
- lib/entity_cache/controls/persist_interval.rb
|
94
94
|
- lib/entity_cache/controls/record.rb
|
95
|
-
- lib/entity_cache/controls/
|
96
|
-
- lib/entity_cache/controls/
|
97
|
-
- lib/entity_cache/controls/
|
98
|
-
- lib/entity_cache/controls/
|
99
|
-
- lib/entity_cache/controls/
|
95
|
+
- lib/entity_cache/controls/store/external.rb
|
96
|
+
- lib/entity_cache/controls/store/external/example.rb
|
97
|
+
- lib/entity_cache/controls/store/external/not_implemented.rb
|
98
|
+
- lib/entity_cache/controls/store/external/write.rb
|
99
|
+
- lib/entity_cache/controls/store/internal.rb
|
100
100
|
- lib/entity_cache/controls/subject.rb
|
101
101
|
- lib/entity_cache/controls/time.rb
|
102
102
|
- lib/entity_cache/controls/version.rb
|
@@ -107,17 +107,17 @@ files:
|
|
107
107
|
- lib/entity_cache/record/destructure.rb
|
108
108
|
- lib/entity_cache/record/log_text.rb
|
109
109
|
- lib/entity_cache/record/transformer.rb
|
110
|
-
- lib/entity_cache/store/
|
111
|
-
- lib/entity_cache/store/
|
112
|
-
- lib/entity_cache/store/
|
113
|
-
- lib/entity_cache/store/
|
114
|
-
- lib/entity_cache/store/
|
115
|
-
- lib/entity_cache/store/
|
116
|
-
- lib/entity_cache/store/
|
117
|
-
- lib/entity_cache/store/
|
118
|
-
- lib/entity_cache/store/
|
119
|
-
- lib/entity_cache/store/
|
120
|
-
- lib/entity_cache/store/
|
110
|
+
- lib/entity_cache/store/external.rb
|
111
|
+
- lib/entity_cache/store/external/null.rb
|
112
|
+
- lib/entity_cache/store/external/substitute.rb
|
113
|
+
- lib/entity_cache/store/external/telemetry.rb
|
114
|
+
- lib/entity_cache/store/internal.rb
|
115
|
+
- lib/entity_cache/store/internal/build.rb
|
116
|
+
- lib/entity_cache/store/internal/build/defaults.rb
|
117
|
+
- lib/entity_cache/store/internal/scope/exclusive.rb
|
118
|
+
- lib/entity_cache/store/internal/scope/global.rb
|
119
|
+
- lib/entity_cache/store/internal/scope/thread.rb
|
120
|
+
- lib/entity_cache/store/internal/substitute.rb
|
121
121
|
- lib/entity_cache/substitute.rb
|
122
122
|
homepage: https://github.com/eventide-project/entity-cache
|
123
123
|
licenses:
|