Skip to main content

Crate use_cache_store

Crate use_cache_store 

Source
Expand description

§use-cache-store

Cache store modeling primitives for RustUse.

§Experimental

use-cache-store is experimental while use-nosql remains below 0.3.0.

§Example

use use_cache_store::{CacheEntry, CacheKey, CacheNamespace, CacheValue, Ttl};

let key = CacheKey::builder()
    .namespace(CacheNamespace::new("reviews"))
    .segment("summary")
    .build();
let entry = CacheEntry::new(key, CacheValue::new("cached")).with_ttl(Ttl::seconds(60)?);

assert_eq!(entry.ttl().map(Ttl::duration).unwrap().as_secs(), 60);

§Scope

  • Cache key, namespace, value, entry, TTL, expiration, status, and eviction labels.
  • Simple key composition primitives.

§Non-goals

  • Redis or Memcached clients.
  • Network calls.
  • Cache invalidation engines.

§License

Licensed under either Apache-2.0 or MIT.

Structs§

CacheEntry
A modeled cache entry.
CacheKey
A cache key.
CacheKeyBuilder
Builder for composed cache keys.
CacheNamespace
A cache namespace.
CacheValue
A cache value payload.
Ttl
A positive time-to-live duration.

Enums§

CacheStatus
Cache entry status labels.
EvictionPolicy
Common cache eviction labels.
Expiration
Cache expiration modeling.
InvalidTtlError
Error returned when a TTL value is invalid.