Sha256: 64bd829d71fe452da77d3b00d1c19b0c1e9210f1bd811857e468c692885832dc

Contents?: true

Size: 927 Bytes

Versions: 15

Compression:

Stored size: 927 Bytes

Contents

require 'thread_safe'

module SplitIoClient
  # A thread-safe in-memory store suitable for use
  # with the Faraday caching HTTP client, uses the
  # Threadsafe gem as the underlying cache.
  #
  class LocalStore
    #
    # 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


    # deletes value from cache by given key
    # @param key [Object] the cache key
    def delete(key)
      @cache[key] = nil
    end

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
splitclient-rb-2.0.1 lib/splitclient-cache/local_store.rb
splitclient-rb-2.0.0 lib/splitclient-cache/local_store.rb
splitclient-rb-1.0.4 lib/splitclient-cache/local_store.rb
splitclient-rb-1.0.4.wip3 lib/splitclient-cache/local_store.rb
splitclient-rb-1.0.4.wip2 lib/splitclient-cache/local_store.rb
splitclient-rb-1.0.4.wip lib/splitclient-cache/local_store.rb
splitclient-rb-1.0.3 lib/splitclient-cache/local_store.rb
splitclient-rb-1.0.3.wip2 lib/splitclient-cache/local_store.rb
splitclient-rb-1.0.3.wip1 lib/splitclient-cache/local_store.rb
splitclient-rb-1.0.2 lib/splitclient-cache/local_store.rb
splitclient-rb-1.0.2.wip2 lib/splitclient-cache/local_store.rb
splitclient-rb-1.0.2.wip lib/splitclient-cache/local_store.rb
splitclient-rb-1.0.1 lib/splitclient-cache/local_store.rb
splitclient-rb-1.0.0 lib/splitclient-cache/local_store.rb
splitclient-rb-0.1.3 lib/splitclient-cache/local_store.rb