Skip to main content

Module id_cache

Module id_cache 

Source
Expand description

ID cache — maps chat identifiers and npubs to SQLite row IDs.

All lookups are cached in memory after first DB hit. Caches are preloaded at boot and cleared on account switch.

Functions§

clear_id_caches
Clear all ID caches (call on account switch).
forget_chat_id
Drop a chat’s cached identifier→id mapping. Call after deleting a chat row so a later recreate doesn’t reuse the stale (now-deleted) integer id.
get_chat_id_by_identifier
Lookup-only: get integer chat ID from identifier. Errors if not found.
get_or_create_chat_id
Get or create integer chat ID from identifier.
get_or_create_user_id
Get or create integer user ID from npub. Returns None for empty npub.
preload_id_caches
Preload all ID mappings into memory cache (call at boot).