Class: ROM::Memory::Storage

Inherits:
Object
  • Object
show all
Defined in:
core/lib/rom/memory/storage.rb

Overview

In-memory thread-safe data storage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStorage

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

#dataThreadSafe::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

Returns:

  • (ThreadSafe::Hash)


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.

Returns:



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

Returns:



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

Returns:

  • (Boolean)


47
48
49
# File 'core/lib/rom/memory/storage.rb', line 47

def key?(name)
  data.key?(name)
end

#sizeInteger

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

Returns:

  • (Integer)


56
57
58
# File 'core/lib/rom/memory/storage.rb', line 56

def size
  data.size
end