Class: LaunchDarkly::Impl::ThreadSafeMemoryStore Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A thread-safe in-memory store that uses the same semantics that Faraday would expect, although we no longer use Faraday. This is used by Requestor, when we are not in a Rails environment.

Since:

  • 5.5.0

Instance Method Summary collapse

Constructor Details

#initializeThreadSafeMemoryStore

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Default constructor

Since:

  • 5.5.0



12
13
14
# File 'lib/ldclient-rb/impl/cache_store.rb', line 12

def initialize
  @cache = Concurrent::Map.new
end

Instance Method Details

#delete(key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Delete a value in the cache

Parameters:

  • key (Object)

    the cache key

Since:

  • 5.5.0



38
39
40
# File 'lib/ldclient-rb/impl/cache_store.rb', line 38

def delete(key)
  @cache.delete(key)
end

#read(key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Read a value from the cache

Parameters:

  • key (Object)

    the cache key

Returns:

  • (Object)

    the cache value

Since:

  • 5.5.0



21
22
23
# File 'lib/ldclient-rb/impl/cache_store.rb', line 21

def read(key)
  @cache[key]
end

#write(key, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

Since:

  • 5.5.0



31
32
33
# File 'lib/ldclient-rb/impl/cache_store.rb', line 31

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