TtlPlugin class
TTL Plugin - Time-To-Live expiration management.
Bundles TTL conditions and hooks for easy installation.
Features
- Expiration check: Blocks reads for expired entries
- Cleanup hook: Returns HiDelete for expired entries (optional)
- Stamp hook: Sets created_at on writes (optional)
Example
final engine = HiEngine();
TtlPlugin().install(engine);
// With all features enabled
TtlPlugin(
enableCleanup: true,
enableStamp: true,
readEvents: ['read', 'get'],
writeEvents: ['write', 'put'],
).install(engine);
Constructors
-
TtlPlugin({String metaKey = 'meta', String createdAtKey = 'created_at', String ttlSecondsKey = 'ttl_seconds', List<
String> readEvents = const ['read'], List<String> writeEvents = const ['write', 'put'], bool enableCleanup = true, bool enableStamp = true, int nowProvider()?}) - Creates a TTL plugin with configurable options.
Properties
- condition → HiCond
-
The TTL condition for checking expiration.
latefinal
- createdAtKey → String
-
Key in meta for creation timestamp.
final
- enableCleanup → bool
-
Whether to register cleanup hook (returns HiDelete for expired).
final
- enableStamp → bool
-
Whether to register stamp hook (sets created_at on writes).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- metaKey → String
-
Metadata key in ctx.data for entry metadata.
final
- nowProvider → int Function()?
-
Custom time provider for testing.
final
-
readEvents
→ List<
String> -
Events to check for expiration.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- ttlSecondsKey → String
-
Key in meta for TTL duration in seconds.
final
-
writeEvents
→ List<
String> -
Events to stamp with creation time.
final
Methods
-
build(
) → HiPlugin - Builds the HiPlugin for installation.
-
install(
HiEngine engine) → void - Convenience method to build and install in one step.
-
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