Skip to main content

Crate cuckoo_cache

Crate cuckoo_cache 

Source
Expand description

Cuckoo hash based cache storage engine with fixed-size item slots.

This crate implements an array-based cache that uses cuckoo hashing to map keys to one of D=4 candidate positions in a flat array of fixed-size slots. When all candidate positions for a new key are occupied, existing items may be displaced to their alternative positions, up to a configurable depth. If displacement fails, an item is evicted according to the configured policy.

The design is based on the cuckoo storage engine from Pelikan: https://github.com/pelikan-io/pelikan

Goals:

  • O(1) lookup with bounded worst case
  • fixed per-item memory overhead
  • bounded insertion latency via displacement limits

Non-goals:

  • not designed for concurrent access
  • not suited for items larger than the configured slot size

Structs§

Builder
A builder used to configure and construct a CuckooCache.
CuckooCache
A pre-allocated cache that uses cuckoo hashing with D=4 candidate positions per key. Items are stored inline in fixed-size slots within a contiguous array.
Item
A read-only view of an item stored in the cuckoo cache.

Enums§

CuckooCacheError
Possible errors returned by the cuckoo cache API.
Policy
Eviction policy used when all candidate positions are occupied and displacement cannot free a slot.
Value