DiskBasedResponseCache class

A ResponseCache that persists ChatResponses as JSON files on disk.

Each entry consists of two files:

  • <hash>.json — the serialized ChatResponse
  • <hash>.expiry — the expiry timestamp (ISO-8601)
Implemented types
Annotations
  • @Source(name: 'DiskBasedResponseCache.cs', namespace: 'Microsoft.Extensions.AI.Evaluation.Reporting.Storage', repository: 'dotnet/extensions', path: 'src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Storage/')

Constructors

DiskBasedResponseCache(String cacheDir, {Duration timeToLive = const Duration(days: 14), DateTime clock()?})
Creates a DiskBasedResponseCache under cacheDir.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

deleteExpiredEntries() Future<void>
Removes all expired entries from the cache.
override
get(String key) Future<ChatResponse?>
Returns the cached ChatResponse for key, or null if not found or expired.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(String key) Future<void>
Removes the entry for key from the cache.
override
reset() Future<void>
Clears all entries from the cache.
override
set(String key, ChatResponse response) Future<void>
Stores response in the cache under key.
override
toString() String
A string representation of this object.
inherited

Operators

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