Struct pingora_cache::key::CacheKey
source · pub struct CacheKey {
pub user_tag: String,
/* private fields */
}
Expand description
General purpose cache key
Fields§
§user_tag: String
An extra tag for identifying users
For example, if the storage backend implements per user quota, this tag can be used.
Implementations§
source§impl CacheKey
impl CacheKey
sourcepub fn set_variance_key(&mut self, key: HashBinary)
pub fn set_variance_key(&mut self, key: HashBinary)
Set the value of the variance hash
sourcepub fn get_variance_key(&self) -> Option<&HashBinary>
pub fn get_variance_key(&self) -> Option<&HashBinary>
Get the value of the variance hash
sourcepub fn remove_variance_key(&mut self)
pub fn remove_variance_key(&mut self)
Removes the variance from this cache key
source§impl CacheKey
impl CacheKey
sourcepub fn default(req_header: &ReqHeader) -> Self
pub fn default(req_header: &ReqHeader) -> Self
Create a default CacheKey from a request, which just takes it URI as the primary key.
sourcepub fn new<S1, S2, S3>(namespace: S1, primary: S2, user_tag: S3) -> Self
pub fn new<S1, S2, S3>(namespace: S1, primary: S2, user_tag: S3) -> Self
Create a new CacheKey from the given namespace, primary, and user_tag string.
Both namespace
and primary
will be used for the primary hash
sourcepub fn primary_key(&self) -> &str
pub fn primary_key(&self) -> &str
Return the primary key of this key
sourcepub fn to_compact(&self) -> CompactCacheKey
pub fn to_compact(&self) -> CompactCacheKey
Convert this key to CompactCacheKey.
Trait Implementations§
source§impl CacheHashKey for CacheKey
impl CacheHashKey for CacheKey
source§fn primary_bin(&self) -> HashBinary
fn primary_bin(&self) -> HashBinary
Return the hash of the cache key
source§fn variance_bin(&self) -> Option<HashBinary>
fn variance_bin(&self) -> Option<HashBinary>
Return the variance hash of the cache key. Read more
source§fn combined_bin(&self) -> HashBinary
fn combined_bin(&self) -> HashBinary
Return the hash including both primary and variance keys
source§fn primary(&self) -> String
fn primary(&self) -> String
The hex string of Self::primary_bin()
source§fn combined(&self) -> String
fn combined(&self) -> String
The hex string of Self::combined_bin()
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