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.