C++ Server-Side SDK Redis Source
Provide SDK data via Redis
Classes | Macros | Typedefs | Functions
redis_big_segment_store.h File Reference

LaunchDarkly Server-side Redis Big Segments Store C Binding. More...

#include <launchdarkly/bindings/c/export.h>
#include <stdbool.h>
Include dependency graph for redis_big_segment_store.h:

Go to the source code of this file.

Classes

struct  LDServerBigSegmentsRedisResult
 Stores the result of calling LDServerBigSegmentsRedisStore_New. More...
 

Macros

#define LDSERVER_BIGSEGMENTS_REDISSTORE_ERROR_MESSAGE_SIZE   256
 

Typedefs

typedef struct _LDServerBigSegmentsRedisStore * LDServerBigSegmentsRedisStore
 LDServerBigSegmentsRedisStore is a Big Segments persistent store for the Server-Side SDK backed by Redis. It is meant to be passed to the SDK via the Big Segments config builder. More...
 

Functions

 LDServerBigSegmentsRedisStore_New (char const *uri, char const *prefix, struct LDServerBigSegmentsRedisResult *out_result)
 Creates a new Redis Big Segment store suitable for usage in the SDK's Big Segments configuration. More...
 
 LDServerBigSegmentsRedisStore_Free (LDServerBigSegmentsRedisStore store)
 Frees a Redis Big Segment store pointer. Only necessary to call if not passing ownership to the SDK's Big Segments configuration.
 

Detailed Description

LaunchDarkly Server-side Redis Big Segments Store C Binding.

Typedef Documentation

◆ LDServerBigSegmentsRedisStore

typedef struct _LDServerBigSegmentsRedisStore* LDServerBigSegmentsRedisStore

LDServerBigSegmentsRedisStore is a Big Segments persistent store for the Server-Side SDK backed by Redis. It is meant to be passed to the SDK via the Big Segments config builder.

Call LDServerBigSegmentsRedisStore_New to obtain a new instance. This instance is passed into the SDK's Big Segments configuration.

Example:

// Stack allocate the result struct, which will hold the result pointer or
// an error message.
// Create the Redis Big Segment store, passing in arguments for the URI,
// prefix, and pointer to the result.
if (!LDServerBigSegmentsRedisStore_New("redis://localhost:6379",
"testprefix", &result)) {
// On failure, you may print the error message (result.error_message),
// then exit or return.
}
// Create the Big Segments builder, taking ownership of the store pointer.
LDServerBigSegmentsBuilder bs_builder = LDServerBigSegmentsBuilder_New(
(LDServerBigSegmentStorePtr)result.store);
// Attach the Big Segments builder to the SDK config.
LDServerConfigBuilder cfg_builder = LDServerConfigBuilder_New("sdk-123");
LDServerConfigBuilder_BigSegments(cfg_builder, bs_builder);
LDServerBigSegmentsRedisStore_New(char const *uri, char const *prefix, struct LDServerBigSegmentsRedisResult *out_result)
Creates a new Redis Big Segment store suitable for usage in the SDK's Big Segments configuration.
Definition: redis_big_segment_store.cpp:12
Stores the result of calling LDServerBigSegmentsRedisStore_New.
Definition: redis_big_segment_store.h:78

This implementation is backed by Redis++, a C++ wrapper for the hiredis library.

Function Documentation

◆ LDServerBigSegmentsRedisStore_New()

LDServerBigSegmentsRedisStore_New ( char const *  uri,
char const *  prefix,
struct LDServerBigSegmentsRedisResult out_result 
)

Creates a new Redis Big Segment store suitable for usage in the SDK's Big Segments configuration.

In this system, the SDK will query Redis for Big Segments membership as required, with an in-memory cache to reduce the number of queries.

Data is never written back to Redis by the SDK; the LaunchDarkly Relay Proxy populates the store.

Parameters
uriRedis URI string. Must not be NULL or empty string.
prefixPrefix to use when reading SDK data from Redis. This allows multiple SDK environments to coexist in the same database, or for the SDK's data to coexist with other unrelated data. Must not be NULL.
out_resultPointer to struct where the store pointer or an error message should be stored.
Returns
True if the store was created successfully; out_result->store will contain the pointer. The caller must either free the pointer with LDServerBigSegmentsRedisStore_Free, OR pass it into the SDK's Big Segments configuration which will take ownership (in which case do not call LDServerBigSegmentsRedisStore_Free.)