Search documentation of macula

# macula_pubsub_cache (macula v0.44.2)

View Source

LRU cache for remote subscriber lists. Caches DHT query results to avoid repeated lookups. Wraps macula_cache with subscriber-specific logic.

# Summary

## Types

cache/0

## Functions

clear(Cache)

Clear all entries.

get(Cache, Pattern)

Get entry from cache. Returns {ok, Subscribers, UpdatedCache} or not_found. The updated cache has the entry moved to front (LRU).

invalidate(Cache, Pattern)

Invalidate (remove) entry.

is_expired(Cache, Pattern, TTL)

Check if entry is expired based on TTL. This checks if entry exists and its age exceeds TTL.

max_size(Cache)

Get max size.

new(MaxSize)

Create new cache with max size.

put(Cache, Pattern, Subscribers)

Put entry in cache.

put_with_timestamp(Cache, Pattern, Subscribers, Timestamp)

Put entry with custom timestamp (for testing).

size(Cache)

Get number of entries.

# Types

# cache/0

    -type cache() :: macula_cache:cache().

# Functions

# clear(Cache)

    -spec clear(cache()) -> cache().

Clear all entries.

# get(Cache, Pattern)

    -spec get(cache(), binary()) -> {ok, [map()], cache()} | not_found.

Get entry from cache. Returns {ok, Subscribers, UpdatedCache} or not_found. The updated cache has the entry moved to front (LRU).

# invalidate(Cache, Pattern)

    -spec invalidate(cache(), binary()) -> cache().

Invalidate (remove) entry.

# is_expired(Cache, Pattern, TTL)

    -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.

# max_size(Cache)

    -spec max_size(cache()) -> pos_integer().

Get max size.

# new(MaxSize)

    -spec new(pos_integer()) -> cache().

Create new cache with max size.

# put(Cache, Pattern, Subscribers)

    -spec put(cache(), binary(), [map()]) -> cache().

Put entry in cache.

# put_with_timestamp(Cache, Pattern, Subscribers, Timestamp)

    -spec put_with_timestamp(cache(), binary(), [map()], integer()) -> cache().

Put entry with custom timestamp (for testing).

# size(Cache)

    -spec size(cache()) -> non_neg_integer().

Get number of entries.