Vaultx.Cache.L1 (Vaultx v0.7.0)
View SourceL1 Memory Cache implementation using ETS.
📊 Coverage Note: This module is excluded from test coverage requirements as part of the experimental Cache system. See .coveralls.exs for details.
This module provides high-performance in-memory caching using Erlang Term Storage (ETS). It's optimized for concurrent read/write operations with automatic TTL management and LRU eviction policies.
Features
- High Performance: Sub-microsecond access times
- Concurrent Access: Optimized for high concurrency
- TTL Management: Automatic expiration of cached items
- LRU Eviction: Least Recently Used eviction when memory limits are reached
- Memory Monitoring: Tracks memory usage and enforces limits
- Atomic Operations: Thread-safe operations
Performance Characteristics
- Read latency: ~0.1-1μs
- Write latency: ~1-5μs
- Concurrent readers: Unlimited
- Concurrent writers: Limited by ETS write_concurrency
- Memory overhead: ~40 bytes per entry + data size
Configuration
config :vaultx, :cache,
l1_max_size: 10_000,
l1_ttl_default: :timer.minutes(15),
l1_cleanup_interval: :timer.minutes(5),
l1_eviction_policy: :lru
Summary
Functions
Returns a specification to start this module under a supervisor.
Performs cleanup of expired entries.
Clears L1 cache.
Deletes a value from L1 cache.
Gets a value from L1 cache.
Puts a value into L1 cache.
Starts the L1 cache.
Gets L1 cache statistics.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Performs cleanup of expired entries.
Clears L1 cache.
Deletes a value from L1 cache.
Gets a value from L1 cache.
Puts a value into L1 cache.
Starts the L1 cache.
Gets L1 cache statistics.