MemoryObjectStorage class
An ObjectStorage holding every object in the heap.
The default for tests and for an embedded, ephemeral registry. It implements the contract exactly — ranges, checksum verification, key safety — so a test that passes against it is testing the same semantics the S3 and GCS backends provide, not a simplified stand-in.
It cannot issue presigned URLs; callers stream bytes through instead.
It is bounded by memory. maxTotalBytes caps what it will hold and
throws StorageException past it, rather than growing until the process is
killed. Pass null to disable the cap when a test knows what it is doing.
- Implemented types
Constructors
- MemoryObjectStorage({String id = 'memory', int? maxTotalBytes = 256 * 1024 * 1024})
-
Creates an empty in-memory store holding at most
maxTotalBytes(default 256 MiB).
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
A short identifier for this backend, used in logs and provider
descriptors (
local,s3:my-bucket,gcs:my-bucket).final -
keys
→ Iterable<
String> -
The keys held, in insertion order.
no setter
- length → int
-
The number of objects held.
no setter
- maxTotalBytes → int?
-
The maximum total bytes retained, or
nullfor unbounded.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- supportsPresignedUrls → bool
-
Whether this backend can issue presigned download URLs, so the caller can
decide between redirecting a client and proxying the bytes without first
asking for a URL and handling
null.no setteroverride
Methods
-
close(
) → Future< void> -
Releases any resources (HTTP clients, file handles).
override
-
delete(
String key) → Future< void> -
Deletes
key. Succeeds whether or not it existed.override -
exists(
String key) → Future< bool> -
Whether
keyexists.override -
get(
String key, {ByteRange? range}) → Future< ObjectReader> -
Opens
keyfor reading, optionally restricted torange.override -
head(
String key) → Future< StoredObject?> -
Metadata for
key, ornullif it does not exist.override -
list(
{String? prefix, int? limit}) → Future< List< String> > -
Keys under
prefix, at mostlimitof them, in lexicographic order.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
presignedUrl(
String key, {Duration expiresIn = const Duration(minutes: 15), String? filename, String? contentType}) → Future< Uri?> -
A time-limited URL a client can fetch
keyfrom directly, ornullif this backend cannot issue one.override -
put(
String key, Stream< List< data, {int? length, String contentType = 'application/octet-stream', String? expectedSha256, Map<int> >String, String> metadata = const {}}) → Future<StoredObject> -
Streams
dataintokey, replacing anything already there.override -
toString(
) → String -
A string representation of this object.
inherited
-
usedBytes(
) → Future< int?> -
Total bytes stored, or
nullif the backend cannot compute it cheaply.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited