pub struct CacheBuilderInstance { /* private fields */ }Expand description
Represents a particular instance of a CacheBuilder. It includes extra metadata of the
policy, required to successfully work in all scenarios involving multiple policies.
Implementations§
Source§impl CacheBuilderInstance
impl CacheBuilderInstance
Sourcepub fn max_entries(self, max_entries: usize) -> Self
pub fn max_entries(self, max_entries: usize) -> Self
Sets the maximum number of entries available for the cache.
Indicates that the cache should not be isolated to the policy. The state will be shared across different policy instances and different policies that use the same cache ID.
Sourcepub fn eviction_strategy(self, strategy: EvictionStrategy) -> Self
pub fn eviction_strategy(self, strategy: EvictionStrategy) -> Self
Sets the eviction strategy for this specific cache instance. This overrides the strategy set on the builder.
Sourcepub fn ttl(self, ttl: Duration) -> Self
pub fn ttl(self, ttl: Duration) -> Self
Sets the time-to-live for cached entries. After this duration, entries expire and are lazily removed on the next read.
Note: When using shared caches, all policy instances sharing the cache ID must use the same TTL setting. A cache with TTL enabled serializes values with a TTL envelope; a cache without TTL (or reading with a different encoding) will fail to deserialize the entry and treat it as a cache miss.