Sha256: 8e7ffa89771806b5f517889f6945c2216b29f36d11c6613a4d62f303e0408cfb

Contents?: true

Size: 1.01 KB

Versions: 34

Compression:

Stored size: 1.01 KB

Contents

require 'concurrent/hash'
require 'concurrent/array'

require 'rom/memory/dataset'

module ROM
  module Memory
    # In-memory thread-safe data storage
    #
    # @private
    class Storage
      # Dataset registry
      #
      # @return [ThreadSafe::Hash]
      #
      # @api private
      attr_reader :data

      # @api private
      def initialize
        @data = Concurrent::Hash.new
      end

      # @return [Dataset]
      #
      # @api private
      def [](name)
        data[name]
      end

      # Register a new dataset
      #
      # @return [Dataset]
      #
      # @api private
      def create_dataset(name)
        data[name] = Dataset.new(Concurrent::Array.new)
      end

      # Check if there's dataset under specified key
      #
      # @return [Boolean]
      #
      # @api private
      def key?(name)
        data.key?(name)
      end

      # Return registered datasets count
      #
      # @return [Integer]
      #
      # @api private
      def size
        data.size
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
rom-core-4.2.1 lib/rom/memory/storage.rb
rom-core-4.2.0 lib/rom/memory/storage.rb
rom-core-4.1.2 lib/rom/memory/storage.rb
rom-core-4.1.1 lib/rom/memory/storage.rb
rom-core-4.1.0 lib/rom/memory/storage.rb
rom-core-4.0.2 lib/rom/memory/storage.rb
rom-core-4.0.1 lib/rom/memory/storage.rb
rom-3.3.3 lib/rom/memory/storage.rb
rom-core-4.0.0 lib/rom/memory/storage.rb
rom-3.3.2 lib/rom/memory/storage.rb
rom-core-4.0.0.rc2 lib/rom/memory/storage.rb
rom-core-4.0.0.rc1 lib/rom/memory/storage.rb
rom-core-4.0.0.beta3 lib/rom/memory/storage.rb
rom-3.3.1 lib/rom/memory/storage.rb
rom-core-4.0.0.beta2 lib/rom/memory/storage.rb
rom-3.3.0 lib/rom/memory/storage.rb
rom-core-4.0.0.beta1 lib/rom/memory/storage.rb
rom-3.2.3 lib/rom/memory/storage.rb
rom-3.2.2 lib/rom/memory/storage.rb
rom-3.2.1 lib/rom/memory/storage.rb