pub struct RedisServer { /* private fields */ }Expand description
Builder for a Redis server.
Implementations§
Source§impl RedisServer
impl RedisServer
Sourcepub fn protected_mode(self, protected: bool) -> Self
pub fn protected_mode(self, protected: bool) -> Self
Enable or disable protected mode (default: off).
Sourcepub fn tcp_backlog(self, backlog: u32) -> Self
pub fn tcp_backlog(self, backlog: u32) -> Self
Set the TCP backlog queue length.
Sourcepub fn unixsocket(self, path: impl Into<PathBuf>) -> Self
pub fn unixsocket(self, path: impl Into<PathBuf>) -> Self
Set a Unix socket path for connections.
Sourcepub fn unixsocketperm(self, perm: u32) -> Self
pub fn unixsocketperm(self, perm: u32) -> Self
Set Unix socket permissions (e.g. 700).
Sourcepub fn timeout(self, seconds: u32) -> Self
pub fn timeout(self, seconds: u32) -> Self
Close idle client connections after this many seconds (0 = disabled).
Sourcepub fn tcp_keepalive(self, seconds: u32) -> Self
pub fn tcp_keepalive(self, seconds: u32) -> Self
Set TCP keepalive interval in seconds.
Sourcepub fn tls_cert_file(self, path: impl Into<PathBuf>) -> Self
pub fn tls_cert_file(self, path: impl Into<PathBuf>) -> Self
Set the TLS certificate file path.
Sourcepub fn tls_key_file(self, path: impl Into<PathBuf>) -> Self
pub fn tls_key_file(self, path: impl Into<PathBuf>) -> Self
Set the TLS private key file path.
Sourcepub fn tls_ca_cert_file(self, path: impl Into<PathBuf>) -> Self
pub fn tls_ca_cert_file(self, path: impl Into<PathBuf>) -> Self
Set the TLS CA certificate file path.
Sourcepub fn tls_auth_clients(self, require: bool) -> Self
pub fn tls_auth_clients(self, require: bool) -> Self
Require TLS client authentication.
Sourcepub fn loglevel(self, level: LogLevel) -> Self
pub fn loglevel(self, level: LogLevel) -> Self
Set the log level (default: LogLevel::Notice).
Sourcepub fn logfile(self, path: impl Into<String>) -> Self
pub fn logfile(self, path: impl Into<String>) -> Self
Set the log file path. Defaults to redis.log inside the node directory.
Sourcepub fn maxmemory(self, limit: impl Into<String>) -> Self
pub fn maxmemory(self, limit: impl Into<String>) -> Self
Set the maximum memory limit (e.g. "256mb", "1gb").
Sourcepub fn maxmemory_policy(self, policy: impl Into<String>) -> Self
pub fn maxmemory_policy(self, policy: impl Into<String>) -> Self
Set the eviction policy when maxmemory is reached.
Sourcepub fn maxclients(self, n: u32) -> Self
pub fn maxclients(self, n: u32) -> Self
Set the maximum number of simultaneous client connections.
Sourcepub fn appendonly(self, appendonly: bool) -> Self
pub fn appendonly(self, appendonly: bool) -> Self
Enable or disable AOF persistence.
Sourcepub fn replicaof(self, host: impl Into<String>, port: u16) -> Self
pub fn replicaof(self, host: impl Into<String>, port: u16) -> Self
Configure this server as a replica of the given master.
Sourcepub fn masterauth(self, password: impl Into<String>) -> Self
pub fn masterauth(self, password: impl Into<String>) -> Self
Set the password for authenticating with a master.
Sourcepub fn password(self, password: impl Into<String>) -> Self
pub fn password(self, password: impl Into<String>) -> Self
Set a requirepass password for client connections.
Sourcepub fn cluster_enabled(self, enabled: bool) -> Self
pub fn cluster_enabled(self, enabled: bool) -> Self
Enable Redis Cluster mode.
Sourcepub fn cluster_node_timeout(self, ms: u64) -> Self
pub fn cluster_node_timeout(self, ms: u64) -> Self
Set the cluster node timeout in milliseconds.
Sourcepub fn loadmodule(self, path: impl Into<PathBuf>) -> Self
pub fn loadmodule(self, path: impl Into<PathBuf>) -> Self
Load a Redis module at startup.
Sourcepub fn io_threads(self, n: u32) -> Self
pub fn io_threads(self, n: u32) -> Self
Set the number of I/O threads.
Sourcepub fn io_threads_do_reads(self, enable: bool) -> Self
pub fn io_threads_do_reads(self, enable: bool) -> Self
Enable I/O threads for reads as well as writes.
Sourcepub fn notify_keyspace_events(self, events: impl Into<String>) -> Self
pub fn notify_keyspace_events(self, events: impl Into<String>) -> Self
Set keyspace notification events (e.g. "KEA").
Sourcepub fn redis_server_bin(self, bin: impl Into<String>) -> Self
pub fn redis_server_bin(self, bin: impl Into<String>) -> Self
Set a custom redis-server binary path.
Sourcepub fn redis_cli_bin(self, bin: impl Into<String>) -> Self
pub fn redis_cli_bin(self, bin: impl Into<String>) -> Self
Set a custom redis-cli binary path.
Sourcepub fn extra(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn extra(self, key: impl Into<String>, value: impl Into<String>) -> Self
Set an arbitrary config directive not covered by dedicated methods.
Sourcepub async fn start(self) -> Result<RedisServerHandle>
pub async fn start(self) -> Result<RedisServerHandle>
Start the server. Returns a handle that stops the server on Drop.
Verifies that redis-server and redis-cli binaries are available
before attempting to launch anything.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RedisServer
impl RefUnwindSafe for RedisServer
impl Send for RedisServer
impl Sync for RedisServer
impl Unpin for RedisServer
impl UnsafeUnpin for RedisServer
impl UnwindSafe for RedisServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more