Sha256: 61802046899f40eb3ecf728ce53e0567f8b20d9830c3a6781aad323adc7d021b

Contents?: true

Size: 1.03 KB

Versions: 28

Compression:

Stored size: 1.03 KB

Contents

require "thread_safe"

module LaunchDarkly
  # A thread-safe in-memory store suitable for use
  # with the Faraday caching HTTP client. Uses the
  # Threadsafe gem as the underlying cache.
  #
  # @see https://github.com/plataformatec/faraday-http-cache
  # @see https://github.com/ruby-concurrency/thread_safe
  #
  class ThreadSafeMemoryStore
    #
    # Default constructor
    #
    # @return [ThreadSafeMemoryStore] a new store
    def initialize
      @cache = ThreadSafe::Cache.new
    end

    #
    # Read a value from the cache
    # @param key [Object] the cache key
    #
    # @return [Object] the cache value
    def read(key)
      @cache[key]
    end

    #
    # Store a value in the cache
    # @param key [Object] the cache key
    # @param value [Object] the value to associate with the key
    #
    # @return [Object] the value
    def write(key, value)
      @cache[key] = value
    end

    #
    # Delete a value in the cache
    # @param key [Object] the cache key
    def delete(key)
      @cache.delete(key)
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ldclient-rb-2.1.4 lib/ldclient-rb/cache_store.rb
ldclient-rb-2.1.0 lib/ldclient-rb/cache_store.rb
ldclient-rb-2.0.6 lib/ldclient-rb/cache_store.rb
ldclient-rb-2.0.5 lib/ldclient-rb/cache_store.rb
ldclient-rb-2.0.3 lib/ldclient-rb/cache_store.rb
ldclient-rb-2.0.2 lib/ldclient-rb/cache_store.rb
ldclient-rb-2.0.1 lib/ldclient-rb/cache_store.rb
ldclient-rb-0.8.0 lib/ldclient-rb/store.rb