testcontainers-cpp 0.2.0
Native C++20 Testcontainers over the Docker Engine API
Loading...
Searching...
No Matches
testcontainers::modules::RedisContainer Class Reference

A running Redis server: connection getters plus the owned container. More...

#include <testcontainers/modules/Redis.hpp>

Public Member Functions

const std::string & host () const noexcept
 The address a client in the test process connects to.
std::uint16_t port () const noexcept
 The host port published for the server port 6379.
const std::string & password () const noexcept
 The password the server requires; empty when none.
std::string connection_string (int database=0) const
 The connection URL, redis://[:password@]host:port[/database] — for DSN-taking clients and redis-cli -u.
Containercontainer () noexcept
 The underlying container handle: exec redis-cli, read logs, copy files, stop() early, keep() it past the test.
const Containercontainer () const noexcept

Friends

class RedisImage

Detailed Description

A running Redis server: connection getters plus the owned container.

Move-only — it owns the core Container, whose destructor force-removes the server (RAII teardown; container().keep() or reuse opt out, see Container).

Member Function Documentation

◆ host()

const std::string & testcontainers::modules::RedisContainer::host ( ) const
inlinenoexcept

The address a client in the test process connects to.

Resolved once, when the container started.

◆ port()

std::uint16_t testcontainers::modules::RedisContainer::port ( ) const
inlinenoexcept

The host port published for the server port 6379.

Resolved once, when the container started; a container restarted by hand gets fresh ephemeral ports — re-resolve via container() then.

◆ password()

const std::string & testcontainers::modules::RedisContainer::password ( ) const
inlinenoexcept

The password the server requires; empty when none.

◆ connection_string()

std::string testcontainers::modules::RedisContainer::connection_string ( int database = 0) const

The connection URL, redis://[:password@]host:port[/database] — for DSN-taking clients and redis-cli -u.

database is the numeric Redis database index; 0 (the default) emits no path segment. The password is percent-encoded. Clients that take host and port directly (hiredis, Boost.Redis, redis-plus-plus) use host() / port() instead.

◆ container() [1/2]

Container & testcontainers::modules::RedisContainer::container ( )
inlinenoexcept

The underlying container handle: exec redis-cli, read logs, copy files, stop() early, keep() it past the test.

◆ container() [2/2]

const Container & testcontainers::modules::RedisContainer::container ( ) const
inlinenoexcept

◆ RedisImage

friend class RedisImage
friend