EvictionPolicy class

Policy used by CacheManager.evict and by the background eviction scheduler.

The policy is split into two conceptual phases:

  • structural cleanup:
    • expired events
    • author-deleted events
    • superseded replaceable/addressable events
  • cap-based cleanup:
    • keep at most N visible events for some kinds

Protection applies to cap-based cleanup, not to structural cleanup. This is deliberate: protected metadata or contact list kinds should still have old superseded versions removed.

Constructors

EvictionPolicy({bool sweepExpired = true, bool sweepDeleted = true, bool sweepSuperseded = true, bool sweepDeliveredEphemeral = true, bool sweepCompletedDeliveries = true, Duration completedDeliveryRetention = const Duration(hours: 8), bool sweepTerminalFailedDeliveries = false, Duration terminalFailedDeliveryRetention = const Duration(hours: 24), Map<int, int> kindCaps = const {}, Set<int> protectedKinds = kDefaultProtectedKinds, Set<String> protectedEventIds = const {}, Set<String> protectedPubKeys = const {}, Set<String> protectedCoordinates = const {}})
const
EvictionPolicy.safeSweep()
const

Properties

completedDeliveryRetention → Duration
Minimum age (since completedAt) before a delivered record is swept.
final
hashCode → int
The hash code for this object.
no setterinherited
kindCaps → Map<int, int>
final
protectedCoordinates → Set<String>
final
protectedEventIds → Set<String>
final
protectedKinds → Set<int>
final
protectedPubKeys → Set<String>
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sweepCompletedDeliveries → bool
Remove EventDeliveryRecords (and their RelayDeliveryTargets) that reached EventDeliveryStatus.delivered longer than completedDeliveryRetention ago.
final
sweepDeleted → bool
final
sweepDeliveredEphemeral → bool
final
sweepExpired → bool
final
sweepSuperseded → bool
final
sweepTerminalFailedDeliveries → bool
Remove terminally failed EventDeliveryRecords (status EventDeliveryStatus.failed) older than terminalFailedDeliveryRetention.
final
terminalFailedDeliveryRetention → Duration
Minimum age (since updatedAt) before a failed record is swept.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

kDefaultProtectedKinds → const Set<int>