ZenithPartitionedStorage class
A tenant-namespaced storage wrapper.
All keys passed to read / write are prefixed with
tenants/{tenantId}/ so that data from different users can never collide
in the same underlying StorageDriver.
final driver = InMemoryStorageDriver();
final storageA = ZenithPartitionedStorage(driver: driver, tenantId: 'user_a');
final storageB = ZenithPartitionedStorage(driver: driver, tenantId: 'user_b');
await storageA.write('token', 'abc');
expect(await storageB.read('token'), isNull); // Isolation verified.
Constructors
- ZenithPartitionedStorage({required StorageDriver driver, required String tenantId})
-
Creates a ZenithPartitionedStorage for
tenantIdbacked bydriver.
Properties
- driver → StorageDriver
-
The backing storage driver shared by all tenants.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tenantId → String
-
The tenant id used to namespace all keys.
final
Methods
-
delete(
String key) → Future< void> -
Deletes the entry for
keyscoped to this tenant. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
read(
String key) → Future< String?> -
Reads the value for
keyscoped to this tenant, ornullif absent. -
toString(
) → String -
A string representation of this object.
inherited
-
write(
String key, String value) → Future< void> -
Writes
valueforkeyscoped to this tenant.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited