InMemoryStorage class
An in-memory ZenStorage implementation.
Useful for:
- Testing: Inject as a mock without file I/O or platform dependencies.
- Development: Fast iteration without worrying about stale persisted data.
- Session caching: Persist data for the duration of an app session only.
Usage
// In tests:
final storage = InMemoryStorage();
ZenQueryCache.instance.setStorage(storage);
// In development builds:
await Zen.init(
storage: kDebugMode ? InMemoryStorage() : SharedPreferencesStorage(),
);
- Implemented types
Constructors
Properties
Methods
-
clear(
) → void - Removes all entries from the in-memory store.
-
containsKey(
String key) → bool -
Returns true if the store contains an entry for
key. -
delete(
String key) → Future< void> -
Delete data from storage.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
read(
String key) → Future< Map< String, dynamic> ?> -
Read data from storage.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
write(
String key, Map< String, dynamic> json) → Future<void> -
Write data to storage.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited