pub struct CacheKey { /* private fields */ }Expand description
A cache key that uniquely identifies a cached value.
Keys are structured as prefix:namespace:identifier to enable
pattern-based invalidation.
Implementations§
Source§impl CacheKey
impl CacheKey
Sourcepub fn new(namespace: impl Into<String>, identifier: impl Into<String>) -> Self
pub fn new(namespace: impl Into<String>, identifier: impl Into<String>) -> Self
Create a new cache key.
Sourcepub fn with_prefix(
prefix: impl Into<String>,
namespace: impl Into<String>,
identifier: impl Into<String>,
) -> Self
pub fn with_prefix( prefix: impl Into<String>, namespace: impl Into<String>, identifier: impl Into<String>, ) -> Self
Create a cache key with a custom prefix.
Sourcepub fn entity_record<I: Display>(entity: &str, id: I) -> Self
pub fn entity_record<I: Display>(entity: &str, id: I) -> Self
Create a key for a specific entity record.
Sourcepub fn find_unique<I: Display>(entity: &str, field: &str, value: I) -> Self
pub fn find_unique<I: Display>(entity: &str, field: &str, value: I) -> Self
Create a key for a find-unique query.
Sourcepub fn find_many(entity: &str, filter_hash: u64) -> Self
pub fn find_many(entity: &str, filter_hash: u64) -> Self
Create a key for a find-many query with filters.
Sourcepub fn relation<I: Display>(
from_entity: &str,
from_id: I,
relation: &str,
) -> Self
pub fn relation<I: Display>( from_entity: &str, from_id: I, relation: &str, ) -> Self
Create a key for a relation.
Sourcepub fn with_tenant(self, tenant: impl Into<String>) -> Self
pub fn with_tenant(self, tenant: impl Into<String>) -> Self
Set the tenant for multi-tenant apps.
Sourcepub fn identifier(&self) -> &str
pub fn identifier(&self) -> &str
Get the identifier.
Trait Implementations§
impl Eq for CacheKey
impl StructuralPartialEq for CacheKey
Auto Trait Implementations§
impl Freeze for CacheKey
impl RefUnwindSafe for CacheKey
impl Send for CacheKey
impl Sync for CacheKey
impl Unpin for CacheKey
impl UnwindSafe for CacheKey
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