pub struct CacheKey {
pub user_tag: String,
pub extensions: Extensions,
/* private fields */
}Expand description
General purpose cache key.
The primary hash is computed over the exact bytes supplied to CacheKey::new.
Callers that combine multiple logical components, such as a namespace and URL,
must encode their boundaries unambiguously before constructing the key.
§Migration
The former namespace argument has been removed. Concatenating the old namespace
and primary bytes preserves the legacy hash, but also preserves its ambiguous
component boundaries. Switching to an unambiguous encoding changes hashes for
keys with a non-empty namespace, so callers should expect a cold cache.
Fields§
§user_tag: StringAn extra tag for identifying users
For example, if the storage backend implements per user quota, this tag can be used.
extensions: ExtensionsGrab-bag for user-defined extensions. These will not be persisted to disk.
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
Sourcepub fn set_primary_bin_override(&mut self, key: HashBinary)
pub fn set_primary_bin_override(&mut self, key: HashBinary)
Override the primary key hash
Sourcepub fn primary_key_str(&self) -> Option<&str>
pub fn primary_key_str(&self) -> Option<&str>
Try to get primary key as UTF-8 str, if valid
Source§impl CacheKey
impl CacheKey
Sourcepub fn new<B, S>(primary: B, user_tag: S) -> Self
pub fn new<B, S>(primary: B, user_tag: S) -> Self
Create a new CacheKey from the given primary key and user_tag.
Only the primary key will be hashed to produce the primary cache hash.
If the primary contains multiple logical components, callers must frame
them unambiguously, for example by length-prefixing each component.
Sourcepub fn primary_key(&self) -> &[u8] ⓘ
pub fn primary_key(&self) -> &[u8] ⓘ
Return the primary key of this key
Sourcepub fn to_compact(&self) -> CompactCacheKey
pub fn to_compact(&self) -> CompactCacheKey
Convert this key to CompactCacheKey.