FileResponseCache class final

A ResponseCache that stores each response as a file in a directory.

File names are the SHA-256 hex digest of the key, so keys of any length and content are safe. The directory is created on first write. Commit the directory to version control, or restore it from a CI cache, to rerun a suite without calling the model.

Writes are atomic: each response goes to a temporary file first and is then moved into place with a rename, so a concurrent reader (including one in another process) never observes a partially written response.

Implemented types
Available extensions

Constructors

FileResponseCache(String directory)
Creates a cache rooted at directory.

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(String key) Future<String?>
Returns the cached response for key, or null on a miss.
override
toString() String
A string representation of this object.
inherited
wrap(ModelCall call, {required String modelId}) ModelCall

Available on ResponseCache, provided by the NestedModelCallCaching extension

Wraps call so its responses are served from and stored in this cache under modelId.
write(String key, String response) Future<void>
Stores response under key.
override

Operators

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