Class: ROM::Memory::Storage
- Inherits:
-
Object
- Object
- ROM::Memory::Storage
- Defined in:
- 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.
20 21 22 |
# File 'lib/rom/memory/storage.rb', line 20 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
17 18 19 |
# File 'lib/rom/memory/storage.rb', line 17 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.
27 28 29 |
# File 'lib/rom/memory/storage.rb', line 27 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
36 37 38 |
# File 'lib/rom/memory/storage.rb', line 36 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
45 46 47 |
# File 'lib/rom/memory/storage.rb', line 45 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
54 55 56 |
# File 'lib/rom/memory/storage.rb', line 54 def size data.size end |