Sha256: 61e8f343cce7f2b32cb3e02881e57ab7e442cf9091691f58e2caef33d93f57f3

Contents?: true

Size: 1.04 KB

Versions: 15

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

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

15 entries across 15 versions & 1 rubygems

Version Path
rom-core-5.3.2 lib/rom/memory/storage.rb
rom-core-5.3.1 lib/rom/memory/storage.rb
rom-core-5.3.0 lib/rom/memory/storage.rb
rom-core-5.2.6 lib/rom/memory/storage.rb
rom-core-5.2.5 lib/rom/memory/storage.rb
rom-core-5.2.4 lib/rom/memory/storage.rb
rom-core-5.2.3 lib/rom/memory/storage.rb
rom-core-5.2.2 lib/rom/memory/storage.rb
rom-core-5.2.1 lib/rom/memory/storage.rb
rom-core-5.1.2 lib/rom/memory/storage.rb
rom-core-5.1.1 lib/rom/memory/storage.rb
rom-core-5.1.0 lib/rom/memory/storage.rb
rom-core-5.0.2 lib/rom/memory/storage.rb
rom-core-5.0.1 lib/rom/memory/storage.rb
rom-core-5.0.0 lib/rom/memory/storage.rb