import type { Article } from '@/types/nostr' import type { Event } from 'nostr-tools' import { objectCache } from '../objectCache' export async function getCachedArticleById(eventId: string): Promise
{ const cachedById = await objectCache.getById('publication', eventId) if (cachedById) { return cachedById as Article } const cachedByHash = await objectCache.get('publication', eventId) if (cachedByHash) { return cachedByHash as Article } const cachedAuthor = await objectCache.getById('author', eventId) if (cachedAuthor) { return cachedAuthor as Article } const cachedAuthorByHash = await objectCache.get('author', eventId) if (cachedAuthorByHash) { return cachedAuthorByHash as Article } return null } export async function getCachedEventById(eventId: string): Promise { const eventFromPublication = await objectCache.getEventById('publication', eventId) if (eventFromPublication) { return eventFromPublication } const eventFromAuthor = await objectCache.getEventById('author', eventId) if (eventFromAuthor) { return eventFromAuthor } return null }