C++ Server-Side SDK Redis Source
Provide SDK data via Redis
redis_source.hpp
Go to the documentation of this file.
1 
5 #pragma once
6 
7 #include <launchdarkly/server_side/integrations/data_reader/iserialized_data_reader.hpp>
8 
9 #include <tl/expected.hpp>
10 
11 #include <memory>
12 #include <string>
13 
14 namespace sw::redis {
15 class Redis;
16 }
17 
18 namespace launchdarkly::server_side::integrations {
32 class RedisDataSource final : public ISerializedDataReader {
33  public:
49  static tl::expected<std::unique_ptr<RedisDataSource>, std::string> Create(
50  std::string uri,
51  std::string prefix);
52 
53  [[nodiscard]] GetResult Get(ISerializedItemKind const& kind,
54  std::string const& itemKey) const override;
55  [[nodiscard]] AllResult All(ISerializedItemKind const& kind) const override;
56  [[nodiscard]] std::string const& Identity() const override;
57  [[nodiscard]] bool Initialized() const override;
58 
59  ~RedisDataSource() override; // = default
60 
61  private:
62  RedisDataSource(std::unique_ptr<sw::redis::Redis> redis,
63  std::string prefix);
64 
65  [[nodiscard]] std::string key_for_kind(
66  ISerializedItemKind const& kind) const;
67 
68  std::string const prefix_;
69  std::string const inited_key_;
70  std::unique_ptr<sw::redis::Redis> redis_;
71 };
72 } // namespace launchdarkly::server_side::integrations
RedisDataSource represents a data source for the Server-Side SDK backed by Redis. It is meant to be u...
Definition: redis_source.hpp:32
static tl::expected< std::unique_ptr< RedisDataSource >, std::string > Create(std::string uri, std::string prefix)
Creates a new RedisDataSource, or returns an error if construction failed.
Definition: redis_source.cpp:7