C++ Client-Side SDK
LaunchDarkly SDK
Classes | Public Types | Public Member Functions | List of all members
launchdarkly::client_side::flag_manager::ContextIndex Class Reference

#include <context_index.hpp>

Classes

struct  IndexEntry
 

Public Types

using Index = std::vector< IndexEntry >
 

Public Member Functions

 ContextIndex (Index)
 
void Notice (std::string id, std::chrono::time_point< std::chrono::system_clock > timestamp)
 
Index const & Entries () const
 
std::vector< std::string > Prune (std::size_t maxContexts)
 

Detailed Description

Used internally to track which contexts have flag data in the persistent store.

This exists because we can't assume that the persistent store mechanism has an "enumerate all the keys that exist under such-and-such prefix" capability, so we need a table of contents at a fixed location. The only information being tracked here is, for each flag data set that exists in storage,

  1. a context identifier (hashed fully-qualified key) and
  2. timestamp when it was last accessed, to support an LRU eviction pattern.

Member Function Documentation

◆ Notice()

void launchdarkly::client_side::flag_manager::ContextIndex::Notice ( std::string  id,
std::chrono::time_point< std::chrono::system_clock >  timestamp 
)

Indicate that a context was accessed. This will add it to the index if it was not already present. If it was present, then it will update the timestamp for the context.

Parameters
idThe id of the context.
timestampThe time the context is noticed.

◆ Prune()

std::vector< std::string > launchdarkly::client_side::flag_manager::ContextIndex::Prune ( std::size_t  maxContexts)

Prune the index returning a list of the removed context keys

Parameters
maxContextsThe maximum number of contexts to retain.
Returns
A list of the contexts that were pruned.

The documentation for this class was generated from the following files: