Class: ROM::Memory::Storage
- Inherits:
-
Object
- Object
- ROM::Memory::Storage
- Defined in:
- core/lib/rom/memory/storage.rb
Overview
In-memory thread-safe data storage
Instance Attribute Summary collapse
-
#data ⇒ ThreadSafe::Hash
readonly
private
Dataset registry.
Instance Method Summary collapse
- #[](name) ⇒ Dataset private
-
#create_dataset(name) ⇒ Dataset
private
Register a new dataset.
-
#initialize ⇒ Storage
constructor
private
A new instance of Storage.
-
#key?(name) ⇒ Boolean
private
Check if there's dataset under specified key.
-
#size ⇒ Integer
private
Return registered datasets count.
Constructor Details
#initialize ⇒ Storage
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Storage.
22 23 24 |
# File 'core/lib/rom/memory/storage.rb', line 22 def initialize @data = Concurrent::Hash.new end |
Instance Attribute Details
#data ⇒ ThreadSafe::Hash (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Dataset registry
19 20 21 |
# File 'core/lib/rom/memory/storage.rb', line 19 def data @data end |
Instance Method Details
#[](name) ⇒ Dataset
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 |
# File 'core/lib/rom/memory/storage.rb', line 29 def [](name) data[name] end |
#create_dataset(name) ⇒ Dataset
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Register a new dataset
38 39 40 |
# File 'core/lib/rom/memory/storage.rb', line 38 def create_dataset(name) data[name] = Dataset.new(Concurrent::Array.new) end |
#key?(name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if there's dataset under specified key
47 48 49 |
# File 'core/lib/rom/memory/storage.rb', line 47 def key?(name) data.key?(name) end |
#size ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return registered datasets count
56 57 58 |
# File 'core/lib/rom/memory/storage.rb', line 56 def size data.size end |