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

BlossomCache()

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. Returns true if it existed. Manual deletion ignores pins, whoever holds them.
get(String sha256) → Future<Uint8List?>
Returns the bytes for sha256, or null if absent.
Returns the descriptor for sha256 without loading the bytes, or null if 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. Returns true if by was added, false if it already held a pin or the blob does not exist.
put(Uint8List bytes, {String? sha256, String? type, String? pinBy}) → Future<BlobDescriptor>
Stores bytes and 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. Returns true if by was removed, false if 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.