• aeromilai 7 hours ago |
    I just released tiered-cache, a high-performance caching library that automatically manages multiple memory tiers. I'd love your feedback and contributions!

    Why another cache library? Most cache needs predefine by number of items capacity, this one's capacity is defined by the bytes given to it, so it provides more precise memory control and prevents unexpected memory growth. Rather than limiting by an arbitrary count of items, you can directly manage the actual memory footprint based on your system's constraints. This is particularly useful when cached items have varying sizes or when working in memory-constrained environments.

    This implementation also focuses on automatic tier management and memory efficiency. It intelligently places items in different tiers based on their size, making it ideal for applications that handle varied data sizes.

    Key Features:

    Zero unsafe code

    Async support with Tokio

    Automatic item placement across tiers

    Built-in monitoring and statistics

    Thread-safe with DashMap

    Efficient concurrent lookups

    Simple API with type-safe interfaces

    Quick Example:

    let config = CacheConfig { tiers: vec![ TierConfig { total_capacity: 100 * MB, // Hot tier: 100MB size_range: (0, 64 * 1024), // For items 0-64KB }, TierConfig { total_capacity: 900 * MB, // Warm tier: 900MB size_range: (64 * 1024, MB), // For items 64KB-1MB }, ], update_channel_size: 1024, };

    let cache = AutoCache::<Vec<u8>, Vec<u8>>::new(config); Check it out on crates.io and the GitHub repo!

    I'm particularly interested in feedback on:

    Performance optimizations

    API ergonomics

    Additional features you'd find useful

    Documentation improvements

    Let me know what you think! PRs and issues are welcome

    • wmf 7 hours ago |
      Can you explain the purpose of tiers? Is it to reduce fragmentation?