TaggedCache

Struct TaggedCache 

Source
pub struct TaggedCache<C: CacheStore> { /* private fields */ }
Expand description

Cache with tag-based invalidation support

Implementations§

Source§

impl<C: CacheStore> TaggedCache<C>

Source

pub fn new(cache: Arc<C>) -> Self

Create new tagged cache

§Examples
use armature_cache::*;

let cache = RedisCache::new(config).await?;
let tagged = TaggedCache::new(Arc::new(cache));
Source

pub async fn set_with_tags( &self, key: &str, value: String, tags: &[&str], ttl: Option<Duration>, ) -> CacheResult<()>

Set a value with tags

§Examples
tagged.set_with_tags(
    "user:123",
    user_json,
    &["users", "active-users"],
    Some(Duration::from_secs(3600)),
).await?;
Source

pub async fn get(&self, key: &str) -> CacheResult<Option<String>>

Get value from cache

Source

pub async fn delete(&self, key: &str) -> CacheResult<()>

Delete a specific key

Source

pub async fn invalidate_tag(&self, tag: &str) -> CacheResult<()>

Invalidate all keys with a specific tag

§Examples
// Invalidate all user-related cache entries
tagged.invalidate_tag("users").await?;
Source

pub async fn invalidate_tags(&self, tags: &[&str]) -> CacheResult<()>

Invalidate all keys with any of the specified tags

§Examples
// Invalidate all user and session data
tagged.invalidate_tags(&["users", "sessions"]).await?;
Source

pub async fn get_keys_by_tag(&self, tag: &str) -> Vec<String>

Get all keys with a specific tag

Source

pub async fn get_tags_for_key(&self, key: &str) -> Vec<String>

Get all tags for a specific key

Source

pub async fn list_tags(&self) -> Vec<String>

Get all registered tags

Trait Implementations§

Source§

impl<C: CacheStore> Clone for TaggedCache<C>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<C> Freeze for TaggedCache<C>

§

impl<C> !RefUnwindSafe for TaggedCache<C>

§

impl<C> Send for TaggedCache<C>

§

impl<C> Sync for TaggedCache<C>

§

impl<C> Unpin for TaggedCache<C>

§

impl<C> !UnwindSafe for TaggedCache<C>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V