Sha256: 1283ca6e9ea19f4d8ceb59d668d23bca70a78ee6e852752b5baa4335acb40a12

Contents?: true

Size: 930 Bytes

Versions: 10

Compression:

Stored size: 930 Bytes

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
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ldclient-rb-0.4.0 lib/ldclient-rb/store.rb
ldclient-rb-0.3.0 lib/ldclient-rb/store.rb
ldclient-rb-0.2.0 lib/ldclient-rb/store.rb
ldclient-rb-0.1.3 lib/ldclient-rb/store.rb
ldclient-rb-0.1.1 lib/ldclient-rb/store.rb
ldclient-rb-0.1.0 lib/ldclient-rb/store.rb
ldclient-rb-0.0.10 lib/ldclient-rb/store.rb
ldclient-rb-0.0.9 lib/ldclient-rb/store.rb
ldclient-rb-0.0.8 lib/ldclient-rb/store.rb
ldclient-rb-0.0.7 lib/ldclient-rb/store.rb