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<Self>
pub fn from_env() -> Result<Self>
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<RedisConnection>
pub async fn get_connection(&self) -> Result<RedisConnection>
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>
pub async fn get_multiplexed_connection(&self) -> Result<MultiplexedConnection>
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
Auto Trait Implementations§
impl Freeze for RedisService
impl RefUnwindSafe for RedisService
impl Send for RedisService
impl Sync for RedisService
impl Unpin 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
Mutably borrows from an owned value. Read more
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>
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 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>
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