Sha256: a5416bd64fed18cc34783b30b308a4cf479027e923582dd96168e9f487abbaa8

Contents?: true

Size: 541 Bytes

Versions: 4

Compression:

Stored size: 541 Bytes

Contents

# frozen_string_literal: true

module Lita
  # A simple, in-memory, thread-safe key-value store.
  # @since 5.0.0
  class Store
    # @param internal_store [Hash] A hash-like object to use internally to store data.
    def initialize(internal_store = {})
      @store = internal_store
      @lock = Mutex.new
    end

    # Get a key from the store.
    def [](key)
      @lock.synchronize { @store[key] }
    end

    # Set a key to the given value.
    def []=(key, value)
      @lock.synchronize { @store[key] = value }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rita-5.0.0.alpha.4 lib/lita/store.rb
rita-5.0.0.alpha.3 lib/lita/store.rb
rita-5.0.0.alpha.2 lib/lita/store.rb
rita-5.0.0.alpha.1 lib/lita/store.rb