Search documentation of macula

# macula_bridge_cache (macula v0.44.2)

View Source

Macula Bridge Cache - Caches results from parent DHT queries.

When a DHT query is escalated to a parent level and succeeds, the result is cached locally to avoid repeated parent queries.

Cache characteristics: - TTL-based expiration (configurable per mesh level) - LRU eviction when cache is full - Different TTLs for different mesh levels: - Cluster: 5 minutes (local, changes frequently) - Street: 10 minutes - Neighborhood: 15 minutes - City: 30 minutes - Country+: 60 minutes

# Summary

## Functions

clear(Pid)

Clear entire cache.

delete(Pid, Key)

Delete value from cache.

get(Pid, Key)

Get value from cache.

get_stats(Pid)

Get cache statistics.

handle_call(Request, From, State)
handle_cast(Request, State)
handle_info(Info, State)
init(Config)
put(Pid, Key, Value)

Put value in cache with default TTL.

put(Pid, Key, Value, TTL)

Put value in cache with specific TTL (in seconds).

size(Pid)

Get current cache size.

start_link(Config)

Start bridge cache with registered name.

terminate(Reason, State)

# Functions

# clear(Pid)

    -spec clear(pid()) -> ok.

Clear entire cache.

# delete(Pid, Key)

    -spec delete(pid(), binary()) -> ok.

Delete value from cache.

# get(Pid, Key)

    -spec get(pid(), binary()) -> {ok, term()} | not_found | expired.

Get value from cache.

# get_stats(Pid)

    -spec get_stats(pid()) -> {ok, map()}.

Get cache statistics.

# handle_call(Request, From, State)

# handle_cast(Request, State)

# handle_info(Info, State)

# init(Config)

# put(Pid, Key, Value)

    -spec put(pid(), binary(), term()) -> ok.

Put value in cache with default TTL.

# put(Pid, Key, Value, TTL)

    -spec put(pid(), binary(), term(), pos_integer() | default) -> ok.

Put value in cache with specific TTL (in seconds).

# size(Pid)

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

Get current cache size.

# start_link(Config)

    -spec start_link(map()) -> {ok, pid()} | {error, term()}.

Start bridge cache with registered name.

# terminate(Reason, State)