DiskCache class

A simple key-value disk cache backed by individual JSON files.

Each entry occupies its own file, so a partial write or corruption can never affect other cached values. File names are derived from the SHA-256 hash of the entry key, which keeps arbitrary key strings safe for the filesystem.

Layout: ~/.pub_doctor/cache/<sha256>.json

File content format:

{ "_exp": <epoch_ms>, "_v": 1, "_data": { ... } }

Constructors

DiskCache({String? dir})
Creates a DiskCache rooted at dir.

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

clearAll() Future<void>
Deletes all cached entries by removing the cache directory entirely.
get(String key) Future<Map<String, dynamic>?>
Retrieves the cached value for key, or null if it is missing, expired, or written by an incompatible schema version.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
set(String key, Map<String, dynamic> data, {Duration ttl = const Duration(hours: 24)}) Future<void>
Writes data under key with the given ttl.
stats() Future<({int bytes, int entries})>
Returns the number of cached entries and their total size in bytes.
toString() String
A string representation of this object.
inherited

Operators

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