GC for database - #1474
Draft
TheAwiteb wants to merge 4 commits into
Draft
GC for database#1474TheAwiteb wants to merge 4 commits into
TheAwiteb wants to merge 4 commits into
Conversation
…bage` Added the `collect_garbage` function to the `NostrDatabase` trait. This gives the user (client or relay) direct control over garbage collection timing, removing the need for an automatic runtime on each database. Signed-off-by: Awiteb <a@4rs.nl>
Signed-off-by: Awiteb <a@4rs.nl>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Ensure expired events are correctly removed when calling `NostrDatabase::collect_garbage`. The test saves an expired event and verifies it gets deleted after garbage collection. Signed-off-by: Awiteb <a@4rs.nl>
Adds garbage collection to delete expired events. This implements the `event_expiration` feature, making the database track and manage event expiration. - Creates a new `expirations` database to track events with expiration timestamps - Adds an `is_indexable` field to `TagIndexKeySet` because the `expiration` tag is non-indexable - Bumps the database version to 3 to migrate existing events and populate the expirations tracker Signed-off-by: Awiteb <a@4rs.nl>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A way to clean up database garbage. It has two parts: the database part and the database user part (where the user can be a client or a relay).
The database handles the deletion, and the user manages when and how to collect the garbage. That makes it kinda flexible, crate users don't have to depend on the SDK to clean garbage, so they can handle it themselves however they want.
Also, I named it
NostrDatabase::collect_garbageinstead of naming it specifically after expired events, because a user might wrap our database or implement their own and consider other things garbage too. It just makes more sense to name it like this.Checklist
CHANGELOG.md(if applicable)