BlossomCache class abstract
A local, network-free Blossom blob store.
Blobs are addressed by their sha256 hash. The caller may supply the hash (cheap when it is already known, e.g. from a Blossom server response) or let the cache compute it.
Implementations may be backed by memory, disk, IndexedDB, or anything else. All operations are asynchronous so the same interface fits sync and async backends uniformly.
- Implementers
Constructors
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
-
clearAllLocalData(
) → Future< void> - Removes every blob and its metadata, pinned ones included.
-
delete(
String sha256) → Future< bool> -
Removes the blob with
sha256. Returnstrueif it existed. Manual deletion ignores pins, whoever holds them. -
get(
String sha256) → Future< Uint8List?> -
Returns the bytes for
sha256, ornullif absent. -
head(
String sha256) → Future< BlobDescriptor?> -
Returns the descriptor for
sha256without loading the bytes, ornullif absent. Equivalent to a Blossom HEAD request. -
list(
) → Future< List< BlobDescriptor> > - Lists every blob descriptor currently held by the cache.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pin(
String sha256, {String by = defaultHolder}) → Future< bool> -
Pins the blob on behalf of
by. Automatic eviction skips a blob while at least one holder pins it. Returnstrueifbywas added,falseif it already held a pin or the blob does not exist. -
put(
Uint8List bytes, {String? sha256, String? type, String? pinBy}) → Future< BlobDescriptor> -
Stores
bytesand returns the descriptor. -
toString(
) → String -
A string representation of this object.
inherited
-
unpin(
String sha256, {String by = defaultHolder}) → Future< bool> -
Releases the pin held by
by. The blob stays pinned if other holders remain. Returnstrueifbywas removed,falseif it held no pin or the blob does not exist. -
unpinAll(
String by) → Future< int> -
Releases every pin held by
by, e.g. when an account logs out. Returns the number of blobs that lost a pin.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- defaultHolder → const String
- Holder used by pin and unpin when the caller does not name one.