macula_pubsub_cache (macula v0.14.3)
View SourceLRU cache for remote subscriber lists. Caches DHT query results to avoid repeated lookups. Wraps macula_cache with subscriber-specific logic.
Summary
Functions
Clear all entries.
Get entry from cache. Returns {ok, Subscribers, UpdatedCache} or not_found. The updated cache has the entry moved to front (LRU).
Invalidate (remove) entry.
Check if entry is expired based on TTL. This checks if entry exists and its age exceeds TTL.
Get max size.
Create new cache with max size.
Put entry in cache.
Put entry with custom timestamp (for testing).
Get number of entries.
Types
-type cache() :: macula_cache:cache().
Functions
Clear all entries.
Get entry from cache. Returns {ok, Subscribers, UpdatedCache} or not_found. The updated cache has the entry moved to front (LRU).
Invalidate (remove) entry.
-spec is_expired(cache(), binary(), pos_integer()) -> boolean().
Check if entry is expired based on TTL. This checks if entry exists and its age exceeds TTL.
-spec max_size(cache()) -> pos_integer().
Get max size.
-spec new(pos_integer()) -> cache().
Create new cache with max size.
Put entry in cache.
Put entry with custom timestamp (for testing).
-spec size(cache()) -> non_neg_integer().
Get number of entries.