From 4558dd5b3c94db12d0e274d6d5435718d03bf964 Mon Sep 17 00:00:00 2001 From: pippellia-btc Date: Sun, 14 Sep 2025 21:32:43 +0200 Subject: [PATCH] added expiration to "active_pubkeys" HLL --- pkg/pipe/recorder.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/pipe/recorder.go b/pkg/pipe/recorder.go index 586a5b2..1d26b35 100644 --- a/pkg/pipe/recorder.go +++ b/pkg/pipe/recorder.go @@ -60,6 +60,8 @@ const ( KeyKind = "kind" KeyActivePubkeys = "active_pubkeys" KeyTotalPubkeys = "total_pubkeys" + + expiration = 30 * 24 * time.Hour ) func stats(day string) string { return KeyStats + separator + day } @@ -82,6 +84,7 @@ func recordEvent(db redb.RedisDB, event *nostr.Event) error { pipe := db.Client.TxPipeline() pipe.HIncrBy(ctx, stats(today), kind(event.Kind), 1) pipe.PFAdd(ctx, activePubkeys(today), event.PubKey) + pipe.Expire(ctx, activePubkeys(today), 30*expiration) if _, err := pipe.Exec(ctx); err != nil { return fmt.Errorf("failed to record event: pipeline failed: %w", err)