Struct kvarn::comprash::Cache

source ·
pub struct Cache<K, V, H = DefaultHasher> { /* private fields */ }
Expand description

A general cache with size and item count limits.

When size limit is reached, a pseudo-random element is removed and the new one inserted. See Cache::discard_one.

The insert method, Cache::cache, has type-specific implementations. This enables clever inserting of data, independently from this struct. Therefore, the Cache::insert function should only be used in those implementations of this struct.

Implementations§

Creates a new Cache. See Cache and CacheOut for more info about what the parameters do.

Creates a new Cache with size_limit and default max_items.

Clears the cache.

Get value at key from the cache.

See HashMap::get for more info.

Gets the CacheItem at key from the cache. Consider using Self::get for most operations.

This includes all lifetime information about the item in the cache. See CacheItem for more info about this.

Get a mutable reference to the value at key from the cache.

See HashMap::get for more info.

Gets a mutable reference to the CacheItem at key from the cache. Consider using Self::get for most operations.

This includes all lifetime information about the item in the cache. See CacheItem for more info about this.

Returns true if the cache contains key.

See HashMap::contains_key for more info.

Removes a key-value pair from the cache, returning the value, if present.

See HashMap::remove and CacheOut::Present.

Inserts a value at key into this cache. value_length should be the size, in bytes, of value.

See bottom of Cache for more info about when to use this.

Writes to the internal hasher to increase quality of output.

Should be used by implementors of the cache method to add to the internal hasher with their data.

The hasher is used when selecting a item to remove from the cache.

Discards one key-value pair pseudo-randomly.

Caches a CompressedResponse and returns the previous response, if any.

Caches a Bytes and returns the previous bytes, if any.

Trait Implementations§

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more