pub struct RedisService { /* private fields */ }Expand description
Redis service for connection management and operations
§Examples
use mecha10_cli::services::RedisService;
// Create service with default URL
let redis = RedisService::default();
// Create service with custom URL
let redis = RedisService::new("redis://localhost:6380")?;
// Get a connection
let mut conn = redis.get_connection().await?;Implementations§
Source§impl RedisService
impl RedisService
Sourcepub fn from_env() -> Result<RedisService, Error>
pub fn from_env() -> Result<RedisService, Error>
Create a new Redis service with default URL
Reads URL from environment variables in order of precedence:
MECHA10_REDIS_URLREDIS_URL- Default: “redis://localhost:6379”
§Errors
Returns an error if the Redis client cannot be created.
Sourcepub async fn get_connection(&self) -> Result<MultiplexedConnection, Error>
pub async fn get_connection(&self) -> Result<MultiplexedConnection, Error>
Get an async Redis connection
This creates a new connection each time. For long-running operations, consider caching the connection in your code.
§Errors
Returns an error if the connection cannot be established.
Sourcepub async fn get_multiplexed_connection(
&self,
) -> Result<MultiplexedConnection, Error>
pub async fn get_multiplexed_connection( &self, ) -> Result<MultiplexedConnection, Error>
Get a multiplexed async Redis connection
Multiplexed connections allow multiple concurrent operations on the same connection.
§Errors
Returns an error if the connection cannot be established.
Sourcepub async fn check_health(&self, timeout: Duration) -> bool
pub async fn check_health(&self, timeout: Duration) -> bool
Sourcepub async fn is_healthy(&self) -> bool
pub async fn is_healthy(&self) -> bool
Check health with default timeout (2 seconds)
Trait Implementations§
Source§impl Debug for RedisService
impl Debug for RedisService
Source§impl Default for RedisService
impl Default for RedisService
Source§fn default() -> RedisService
fn default() -> RedisService
Create a Redis service with environment-based configuration
§Panics
Panics if the Redis client cannot be created. For error handling,
use RedisService::from_env() instead.
Auto Trait Implementations§
impl Freeze for RedisService
impl RefUnwindSafe for RedisService
impl Send for RedisService
impl Sync for RedisService
impl Unpin for RedisService
impl UnsafeUnpin for RedisService
impl UnwindSafe for RedisService
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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