Class: LaunchDarkly::ThreadSafeMemoryStore

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/store.rb

Overview

A thread-safe in-memory store suitable for use with the Faraday caching HTTP client. Uses the Threadsafe gem as the underlying cache.

Instance Method Summary collapse

Constructor Details

#initializeThreadSafeMemoryStore

Default constructor



17
18
19
# File 'lib/ldclient-rb/store.rb', line 17

def initialize
  @cache = ThreadSafe::Cache.new
end

Instance Method Details

#read(key) ⇒ Object

Read a value from the cache

Parameters:

  • key (Object)

    the cache key

Returns:

  • (Object)

    the cache value



26
27
28
# File 'lib/ldclient-rb/store.rb', line 26

def read(key)
  @cache[key]
end

#write(key, value) ⇒ Object

Store a value in the cache

Parameters:

  • key (Object)

    the cache key

  • value (Object)

    the value to associate with the key

Returns:

  • (Object)

    the value



36
37
38
# File 'lib/ldclient-rb/store.rb', line 36

def write(key, value)
  @cache[key] = value
end