CacheManager class abstract

Storage contract used by NDK.

This is intentionally broader than a plain event store. Modern NDK cache backends persist several related data domains:

  • canonical Nostr events
  • event provenance (source relays)
  • delivery state (EventDeliveryRecord and RelayDeliveryTarget)
  • decrypted plaintext sidecars for encrypted events
  • convenience projections like metadata/contact list/user relay list
  • optional fetched-ranges state

Backend authors should treat this class as a behavior contract, not just a list of CRUD methods. The most important behavioral expectations are:

  • loadEvents returns visible events only
  • metadata/contact list loaders are convenience views over the generic event store, not separate authoritative silos
  • provenance and delivery targets are separate concerns
Implementers

Constructors

CacheManager()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addEventSource({required String eventId, required String relayUrl}) → Future<void>
Adds one provenance relay for a stored event.
addEventSources({required String eventId, required Iterable<String> relayUrls}) → Future<void>
clearAll() → Future<void>
Clears all cached data.
close() → Future<void>
closes the cache manger
used to close the db
evict(EvictionPolicy policy) → Future<EvictionResult>
Run one eviction pass according to policy.
getCashuSecretCounter({required String mintUrl, required String keysetId}) → Future<int>
getKeysets({String? mintUrl}) → Future<List<CahsuKeyset>>
get all keysets if no mintUrl is provided \
getMintInfos({List<String>? mintUrls}) → Future<List<CashuMintInfo>?>
return all if no mintUrls are provided
getProofs({String? mintUrl, String? keysetId, CashuProofState state = CashuProofState.unspend}) → Future<List<CashuProof>>
loadContactList(String pubKey) → Future<ContactList?>
loadDecryptedEventPayloadRecord({required String eventId, required String viewerPubKey}) → Future<DecryptedEventPayloadRecord?>
loadDecryptedEventPayloadRecords({String? eventId, String? viewerPubKey, DecryptedPayloadStatus? status, int? limit}) → Future<List<DecryptedEventPayloadRecord>>
loadEvent(String id) → Future<Nip01Event?>
Loads the raw stored event by id.
loadEventDeliveryRecord(String eventId) → Future<EventDeliveryRecord?>
loadEventDeliveryRecords({EventDeliveryStatus? status, int? limit}) → Future<List<EventDeliveryRecord>>
loadEvents({List<String>? ids, List<String>? pubKeys, List<int>? kinds, Map<String, List<String>>? tags, int? since, int? until, String? search, int? limit}) → Future<List<Nip01Event>>
Load visible events from cache with flexible filtering.
loadEventSources(String eventId) → Future<List<String>>
loadFilterFetchedRangeRecords(String filterHash) → Future<List<FilterFetchedRangeRecord>>
Load all fetched range records for a filter hash
loadFilterFetchedRangeRecordsByRelay(String filterHash, String relayUrl) → Future<List<FilterFetchedRangeRecord>>
Load all fetched range records for a filter hash and relay
loadFilterFetchedRangeRecordsByRelayUrl(String relayUrl) → Future<List<FilterFetchedRangeRecord>>
Load all fetched range records for a relay (all filters)
loadMetadata(String pubKey) → Future<Metadata?>
loadMetadatas(List<String> pubKeys) → Future<List<Metadata?>>
loadNip05({String? pubKey, String? identifier}) → Future<Nip05?>
loadNip05s(List<String> pubKeys) → Future<List<Nip05?>>
loadRelayDeliveryTarget({required String eventId, required String relayUrl}) → Future<RelayDeliveryTarget?>
loadRelayDeliveryTargets({String? eventId, String? relayUrl, RelayDeliveryState? state, bool excludeAcked = false, int? limit}) → Future<List<RelayDeliveryTarget>>
loadRelaySet(String name, String pubKey) → Future<RelaySet?>
loadUserRelayList(String pubKey) → Future<UserRelayList?>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeAllContactLists() → Future<void>
removeAllDecryptedEventPayloadRecords() → Future<void>
removeAllEventDeliveryRecords() → Future<void>
removeAllEvents() → Future<void>
removeAllEventsByPubKey(String pubKey) → Future<void>
removeAllFilterFetchedRangeRecords() → Future<void>
Remove all filter fetched range records
removeAllMetadatas() → Future<void>
removeAllNip05s() → Future<void>
removeAllRelayDeliveryTargets() → Future<void>
removeAllRelaySets() → Future<void>
removeAllUserRelayLists() → Future<void>
removeContactList(String pubKey) → Future<void>
removeDecryptedEventPayloadRecord({required String eventId, required String viewerPubKey}) → Future<void>
removeDecryptedEventPayloadRecords(String eventId) → Future<void>
removeEvent(String id) → Future<void>
removeEventDeliveryRecord(String eventId) → Future<void>
removeEvents({List<String>? ids, List<String>? pubKeys, List<int>? kinds, Map<String, List<String>>? tags, int? since, int? until}) → Future<void>
Remove events from cache with flexible filtering.
removeEventSources(String eventId) → Future<void>
removeFilterFetchedRangeRecords(String filterHash) → Future<void>
Remove all fetched range records for a filter hash
removeFilterFetchedRangeRecordsByFilterAndRelay(String filterHash, String relayUrl) → Future<void>
Remove fetched range records for a specific filter hash and relay
removeFilterFetchedRangeRecordsByRelay(String relayUrl) → Future<void>
Remove all fetched range records for a relay
removeMetadata(String pubKey) → Future<void>
removeMintInfo({required String mintUrl}) → Future<void>
removeNip05(String pubKey) → Future<void>
removeProofs({required List<CashuProof> proofs, required String mintUrl}) → Future<void>
removeRelayDeliveryTarget({required String eventId, required String relayUrl}) → Future<void>
removeRelayDeliveryTargets(String eventId) → Future<void>
removeRelaySet(String name, String pubKey) → Future<void>
removeUserRelayList(String pubKey) → Future<void>
saveContactList(ContactList contactList) → Future<void>
saveContactLists(List<ContactList> contactLists) → Future<void>
saveDecryptedEventPayloadRecord(DecryptedEventPayloadRecord record) → Future<void>
Persist one plaintext sidecar for an encrypted event.
saveDecryptedEventPayloadRecords(List<DecryptedEventPayloadRecord> records) → Future<void>
saveEvent(Nip01Event event) → Future<void>
saveEventDeliveryRecord(EventDeliveryRecord record) → Future<void>
Persist aggregate delivery state for one event.
saveEventDeliveryRecords(List<EventDeliveryRecord> records) → Future<void>
saveEventIfAbsent(Nip01Event event) → Future<bool>
Stores event only when its id is not already present.
saveEvents(List<Nip01Event> events) → Future<void>
saveFilterFetchedRangeRecord(FilterFetchedRangeRecord record) → Future<void>
Save a filter fetched range record
saveFilterFetchedRangeRecords(List<FilterFetchedRangeRecord> records) → Future<void>
Save multiple filter fetched range records
saveKeyset(CahsuKeyset keyset) → Future<void>
cashu methods
saveMetadata(Metadata metadata) → Future<void>
saveMetadatas(List<Metadata> metadatas) → Future<void>
saveMintInfo({required CashuMintInfo mintInfo}) → Future<void>
saveNip05(Nip05 nip05) → Future<void>
saveNip05s(List<Nip05> nip05s) → Future<void>
saveProofs({required List<CashuProof> proofs, required String mintUrl}) → Future<void>
saveRelayDeliveryTarget(RelayDeliveryTarget target) → Future<void>
Persist one relay-specific delivery target.
saveRelayDeliveryTargets(List<RelayDeliveryTarget> targets) → Future<void>
saveRelaySet(RelaySet relaySet) → Future<void>
saveUserRelayList(UserRelayList userRelayList) → Future<void>
Store a precomputed user relay list projection.
saveUserRelayLists(List<UserRelayList> userRelayLists) → Future<void>
searchEvents({List<String>? ids, List<String>? authors, List<int>? kinds, Map<String, List<String>>? tags, int? since, int? until, String? search, int limit = 100}) → Future<Iterable<Nip01Event>>
search events
ids - list of event ids
authors - list of authors pubKeys
kinds - list of kinds
tags - map of tags
since - timestamp
until - timestamp
search - search string to match against content
limit - limit of results
returns list of events
searchMetadatas(String search, int limit) → Future<Iterable<Metadata>>
Search by name, nip05
setCashuSecretCounter({required String mintUrl, required String keysetId, required int counter}) → Future<void>
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited