pub struct RedisCache { /* private fields */ }Expand description
Redis cache for authorization (L2 cache)
Implementations§
Source§impl RedisCache
impl RedisCache
Sourcepub fn new(config: RedisCacheConfig) -> Result<Self>
pub fn new(config: RedisCacheConfig) -> Result<Self>
Create a new Redis cache instance
Sourcepub async fn get_permission(
&self,
key: &PermissionCacheKey,
) -> Result<Option<bool>>
pub async fn get_permission( &self, key: &PermissionCacheKey, ) -> Result<Option<bool>>
Get cached permission result
Sourcepub async fn set_permission(
&self,
key: &PermissionCacheKey,
allowed: bool,
ttl: Option<Duration>,
) -> Result<()>
pub async fn set_permission( &self, key: &PermissionCacheKey, allowed: bool, ttl: Option<Duration>, ) -> Result<()>
Set cached permission result
Sourcepub async fn invalidate(&self, key: &PermissionCacheKey) -> Result<()>
pub async fn invalidate(&self, key: &PermissionCacheKey) -> Result<()>
Invalidate cache entry
Sourcepub async fn invalidate_subject(&self, subject: &Subject) -> Result<()>
pub async fn invalidate_subject(&self, subject: &Subject) -> Result<()>
Invalidate all cache entries for a subject
Sourcepub async fn invalidate_resource(
&self,
namespace: &str,
object_id: &str,
) -> Result<()>
pub async fn invalidate_resource( &self, namespace: &str, object_id: &str, ) -> Result<()>
Invalidate all cache entries for a resource
Sourcepub async fn invalidate_tuple(&self, tuple: &RelationTuple) -> Result<()>
pub async fn invalidate_tuple(&self, tuple: &RelationTuple) -> Result<()>
Invalidate all cache entries affected by a tuple write
Sourcepub async fn stats(&self) -> Result<RedisCacheStats>
pub async fn stats(&self) -> Result<RedisCacheStats>
Get cache statistics
Sourcepub async fn health_check(&self) -> Result<bool>
pub async fn health_check(&self) -> Result<bool>
Health check
Auto Trait Implementations§
impl Freeze for RedisCache
impl !RefUnwindSafe for RedisCache
impl Send for RedisCache
impl Sync for RedisCache
impl Unpin for RedisCache
impl !UnwindSafe for RedisCache
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