Class: ROM::Memory::Storage

Inherits:
Object
  • Object
show all
Defined in:
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.



20
21
22
# File 'lib/rom/memory/storage.rb', line 20

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)


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.

Returns:



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

Returns:



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

Returns:

  • (Boolean)


45
46
47
# File 'lib/rom/memory/storage.rb', line 45

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)


54
55
56
# File 'lib/rom/memory/storage.rb', line 54

def size
  data.size
end