Nostr.Cache (nostr_access v0.3.3)
View SourceCache management for Nostr events with three-tier caching:
- Zero results cache (TTL: 1 hour)
- Immutable results cache (TTL: 1 day) - for queries with specific event IDs
- Mutable results cache (TTL: 30 minutes) - for all other queries
Summary
Functions
Determines which cache table to use based on filter and results.
Gets a value from the appropriate cache based on filter.
Gets a value from cache or stores the result of the given function.
Gets a value from the zero results cache.
Creates a cache key from relays and filter.
Stores events in the appropriate cache based on filter and results.
Stores zero results in the zero results cache.
Tries to get a value from all cache tables in order of preference.
Functions
Determines which cache table to use based on filter and results.
Gets a value from the appropriate cache based on filter.
Gets a value from cache or stores the result of the given function.
Gets a value from the zero results cache.
Creates a cache key from relays and filter.
Stores events in the appropriate cache based on filter and results.
@spec put_zero_results( {[String.t()], String.t()}, [map()] ) :: {:ok, boolean()} | {:error, term()}
Stores zero results in the zero results cache.
@spec try_get_from_all_caches( {[String.t()], String.t()}, map() ) :: {:ok, [map()]} | {:error, :not_found}
Tries to get a value from all cache tables in order of preference.