Oddbean new post about | logout
 @utxo the webmaster 🧑‍💻 since your kind of the relay building man. how hard would it be to build a relay implementation that works as a "cache relay"?
It would need to only stores x Gb of events and remove the least accessed events when cleaning up

Id like to have a simple relay to bundle with noStrudel on Start9 and Umbrel that's faster than the browsers cache but also does not get out of hand and fill up the whole machine 
 Why wouldn’t you just run strfry with a background task to clean up every now and then? 
 i got a raspi pi5 running strfry and a 1tb nvme on the local net.  gonna be running some experiments 🦖 
 does it have a clean up job? how does it prioritize what events to remove? 
 It doesn’t but I’m sure you could write a little sidecar program or make a fork and add a bit for garbage collection.  
 Come to think of it, might be a fun project for nostr-rs-relay too. It’s super lightweight and already used SQLite for storage.  
 I've thought about using nostr-rs-relay with a sidecar, but the issue is tracking what events where last used (sent). I'm not sure how to do that 
 ahh, yeah ok - that makes sense. 

Had a quick look at nostr-rs-relay and it looks like all you'd really need is to add a new column to the database to store the last accessed time of the stored event. 

Then you could easily have a background task that ran to clean up. The methods that touch the events would just need to update that field every time the event is returned in a REQed. You'd have to spend a bit of time to make sure you optimized how to do that write... but feels doable to me.  
 Hooking up khatru to a postgres db with some table that purges least recently used? Like with pg_cron 
 Pg is way too slow compared to lmdb and badger is the issue here 
 Honestly I think WoT relay basically does this already paired with lmdb. There is a purge by date function built in and lmdb already handles the caching by accessibility out of the box. While also preventing majority of spam and being able to act as a single local relay by pulling notes from other relays as a background task. 
 Ill give it a try, but I don't want to purge the events by their created_at date. I want to purge them by the last time they where accessed ( i.e. sent to a client ) that way profiles event stay around 
 Fairly certain we only purge kind 1, reactions and zaps 

But to build exactly how you want it wouldn't be that hard either, a little patch and just added a map in ram with last accessed by and some job to purge by 

 
 nostr:nprofile1qqsw9n8heusyq0el9f99tveg7r0rhcu9tznatuekxt764m78ymqu36cpr9mhxue69uhhyetvv9ujuat50phjummwv5hkx6rpwsq32amnwvaz7tmxwfjkuueww468smewdahx2tcpz4mhxue69uhhyetvv9ujuat50phjummwv5hs9smu6e
Yes please.
Wonder how primal's cache could he leveraged to this extent?
nostr:nprofile1qqsdv8emcke7k3qqaldwv956tstu40ejg663gdsaayuuujs6pknw7jspz3mhxue69uhhyetvv9ujucn0w3jhvtnnwcq3yamnwvaz7tmsw4e8qmr9wpskwtn9wvqs6amnwvaz7tmwdaejumr0dsx2l4qj 
 t-y hzrd149/