Skip to main content

RedisServer

Struct RedisServer 

Source
pub struct RedisServer { /* private fields */ }
Expand description

Builder for a Redis server.

Implementations§

Source§

impl RedisServer

Source

pub fn new() -> Self

Source

pub fn port(self, port: u16) -> Self

Set the listening port (default: 6379).

Source

pub fn bind(self, bind: impl Into<String>) -> Self

Set the bind address (default: 127.0.0.1).

Source

pub fn protected_mode(self, protected: bool) -> Self

Enable or disable protected mode (default: off).

Source

pub fn tcp_backlog(self, backlog: u32) -> Self

Set the TCP backlog queue length.

Source

pub fn unixsocket(self, path: impl Into<PathBuf>) -> Self

Set a Unix socket path for connections.

Source

pub fn unixsocketperm(self, perm: u32) -> Self

Set Unix socket permissions (e.g. 700).

Source

pub fn timeout(self, seconds: u32) -> Self

Close idle client connections after this many seconds (0 = disabled).

Source

pub fn tcp_keepalive(self, seconds: u32) -> Self

Set TCP keepalive interval in seconds.

Source

pub fn tls_port(self, port: u16) -> Self

Set TLS listening port.

Source

pub fn tls_cert_file(self, path: impl Into<PathBuf>) -> Self

Set the TLS certificate file path.

Source

pub fn tls_key_file(self, path: impl Into<PathBuf>) -> Self

Set the TLS private key file path.

Source

pub fn tls_ca_cert_file(self, path: impl Into<PathBuf>) -> Self

Set the TLS CA certificate file path.

Source

pub fn tls_auth_clients(self, require: bool) -> Self

Require TLS client authentication.

Source

pub fn dir(self, dir: impl Into<PathBuf>) -> Self

Set the working directory for data files.

Source

pub fn loglevel(self, level: LogLevel) -> Self

Set the log level (default: LogLevel::Notice).

Source

pub fn databases(self, n: u32) -> Self

Set the number of databases (default: 16).

Source

pub fn maxmemory(self, limit: impl Into<String>) -> Self

Set the maximum memory limit (e.g. "256mb", "1gb").

Source

pub fn maxmemory_policy(self, policy: impl Into<String>) -> Self

Set the eviction policy when maxmemory is reached.

Source

pub fn maxclients(self, n: u32) -> Self

Set the maximum number of simultaneous client connections.

Source

pub fn save(self, save: bool) -> Self

Enable or disable RDB snapshots (default: off).

Source

pub fn appendonly(self, appendonly: bool) -> Self

Enable or disable AOF persistence.

Source

pub fn replicaof(self, host: impl Into<String>, port: u16) -> Self

Configure this server as a replica of the given master.

Source

pub fn masterauth(self, password: impl Into<String>) -> Self

Set the password for authenticating with a master.

Source

pub fn password(self, password: impl Into<String>) -> Self

Set a requirepass password for client connections.

Source

pub fn acl_file(self, path: impl Into<PathBuf>) -> Self

Set the path to an ACL file.

Source

pub fn cluster_enabled(self, enabled: bool) -> Self

Enable Redis Cluster mode.

Source

pub fn cluster_node_timeout(self, ms: u64) -> Self

Set the cluster node timeout in milliseconds.

Source

pub fn loadmodule(self, path: impl Into<PathBuf>) -> Self

Load a Redis module at startup.

Source

pub fn hz(self, hz: u32) -> Self

Set the server tick frequency in Hz (default: 10).

Source

pub fn io_threads(self, n: u32) -> Self

Set the number of I/O threads.

Source

pub fn io_threads_do_reads(self, enable: bool) -> Self

Enable I/O threads for reads as well as writes.

Source

pub fn notify_keyspace_events(self, events: impl Into<String>) -> Self

Set keyspace notification events (e.g. "KEA").

Source

pub fn redis_server_bin(self, bin: impl Into<String>) -> Self

Set a custom redis-server binary path.

Source

pub fn redis_cli_bin(self, bin: impl Into<String>) -> Self

Set a custom redis-cli binary path.

Source

pub fn extra(self, key: impl Into<String>, value: impl Into<String>) -> Self

Set an arbitrary config directive not covered by dedicated methods.

Source

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§

Source§

impl Default for RedisServer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.