clache 0.1.0

Small utilities for caching data
Documentation
  • Coverage
  • 93.94%
    31 out of 33 items documented2 out of 31 items with examples
  • Size
  • Source code size: 21.58 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.32 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Yrgh/clache
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Yrgh

Lightweight, path-based caching utilities for various use cases.

Clache provides two mechanisms for caching:

  • The GlobalCache requires less boilerplate and can operate on dynamic types. It is more suitable for an asset system, for example.
  • LocalCaches are less flexible, but more efficient. Unlike the GlobalCache, they store static types and are more suitable when paths are not linked to the filesystem, as a single path can be distinctly cached for different instances and types.

Choosing a cache

Use a LocalCache when:

  • Are only caching one, known type.
  • Are making a subsystem or the cache belongs to an object.
  • And want more performance.

Use the GlobalCache when:

  • You want easy shared access.
  • Are caching multiple/dynamic types.
  • Or paths are uniquely identifying.

Async support

Both types of caches support asynchronous loading. Through the get_or_else_async and get_or_try_async functions.

Thread safety

Both types of caches use RwLock internally and share cached values via Arc, making them both thread-safe and efficient.