CacheEvictEvent class final

Event published when an entry is removed (evicted) from a cache.

This event indicates that a cache eviction operation has occurred, either due to explicit removal, TTL expiration, eviction policies, or other cache management rules. Observers can use this event to track cache invalidations, logging, or metrics collection.

Core Properties

  • source: The key of the cache entry that was evicted.
  • cacheName: The name of the cache from which the entry was evicted.
  • reason: The reason for eviction, such as 'manual', 'policy', or 'ttl_expired'.
  • timestamp: Optional timestamp of when the event occurred.

Usage Example

void onCacheEvict(CacheEvictEvent event) {
  print('Evicted key ${event.source} from cache ${event.cacheName} due to ${event.reason}');
}

Observers can use this information to:

  • Track cache eviction patterns.
  • Monitor TTL or policy-driven evictions.
  • Trigger logging, metrics collection, or dependent invalidations.
Inheritance

Constructors

CacheEvictEvent(Object source, String cacheName, String reason, [DateTime? timestamp])
Creates a new cache evict event.
const

Properties

cacheName → String
The name of the cache where this event occurred.
finalinherited
hashCode → int
The hash code for this object.
no setterinherited
reason → String
The reason why the cache entry was evicted.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

equalizedProperties() → List<Object?>
Mixin-style contract for value-based equality, hashCode, and toString.
inherited
getPackageName() → String
Represents an abstraction for identifying the package that an object, resource, or service belongs to.
inherited
getSource() → Object
Returns the source of the event.
inherited
getTimestamp() → DateTime
Returns the timestamp of the event.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override
toStringOptions() → ToStringOptions
inherited

Operators

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