ndk supports the use of client or server-side caches. It currently stores every event it receives and begins flushing older(?) events when it reaches a configurable limit of 10,000.

I think a cache adapter for a local relay would be nice. It could simply look for a local relay on localhost:4869 and use that if it exists; optionally fallbacking to the in-browser dexie adapter.

What do you think nostr:npub1zuuajd7u3sx8xu92yav9jwxpr839cs0kc3q6t56vd5u9q033xmhsk6c2uc nostr:npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft?

Reply to this note

Please Login to reply.

Discussion

yeah, I want to do something like that, it should be pretty trivial to do; all it does is redirect requests to the local relay and forward all events to the local relay when setEvent is called.

It's a good idea.

Keep in mind that Cache and Local Relays are two separate things. They solve different problems. Local relays are about network traffic and data consumption. Local Cache is about pre-indexing the things the app needs.

Local relays communicate with the Nostr REQ API which is extremely limiting for local cache services.

For instance, Local Cache has all the decrypted information the app needs. The Local Relay cannot keep decrypted information ready.