ClientWorkDbLock class

Client implementation of IWorkDb with file-based locking.

This class extends ClientWorkDb and adds file locking to prevent concurrent access to the same items. It uses a separate lock file directory structure for managing locks.

Usage

final db = ClientWorkDbLock(IoWorkDb('./data'));

// Operations are protected by file locks
await db.create(ItemWithId(
  id: 'doc-1',
  collection: 'documents',
  item: {'title': 'Hello'},
));

Lock Configuration

// With default settings (5000ms lock timeout)
final db = ClientWorkDbLock(IoWorkDb('./data'));

// With custom timeout for stale lock detection
final db = ClientWorkDbLock.withWaitingMs(
  IoWorkDb('./data'),
  waitingMs: 300,
);
Inheritance
Implementers

Constructors

ClientWorkDbLock(IWorkFileSystem workDbInternal, {int? maxRecordsPerCollection})
Creates a new ClientWorkDbLock with the given file system backend and file locking enabled.
ClientWorkDbLock.withWaitingMs(IWorkFileSystem workDbInternal, {required int waitingMs, int? maxRecordsPerCollection})
Creates a ClientWorkDbLock with custom lock timeout for stale lock detection.

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

clearDatabase() → Future<void>
Clears all data from the database.
inherited
clearDatabaseSync() → void
Clears all data from the database.
inherited
create(ItemWithId input) → Future<void>
Creates a new item in the database.
override
createMultiple(List<ItemWithId> inputs) → Future<void>
Creates multiple items in the database.
inherited
createMultipleSync(List<ItemWithId> inputs) → void
Creates multiple items in the database.
inherited
createOrUpdate(ItemWithId input) → Future<void>
Creates an item if it doesn't exist, or updates it if it does.
override
createOrUpdateMultiple(List<ItemWithId> inputs) → Future<void>
Creates or updates multiple items in the database.
inherited
createOrUpdateMultipleSync(List<ItemWithId> inputs) → void
Creates or updates multiple items in the database.
inherited
createOrUpdateSync(ItemWithId input) → void
Creates an item if it doesn't exist, or updates it if it does.
inherited
createSync(ItemWithId input) → void
Creates a new item in the database.
inherited
delete(ItemId input) → Future<void>
Deletes an item from the database.
override
deleteCollection(String collection) → Future<void>
Deletes an entire collection from the database.
inherited
deleteCollectionSync(String collection) → void
Deletes an entire collection from the database.
inherited
deleteSync(ItemId input) → void
Deletes an item from the database.
inherited
getCollections() → Future<List<String>>
Returns a list of all collection names in the database.
inherited
getCollectionsSync() → List<String>
Returns a list of all collection names in the database.
inherited
getItemsInCollection(String collection) → Future<List<String>>
Returns a list of all item IDs in a collection.
inherited
getItemsInCollectionSync(String collection) → List<String>
Returns a list of all item IDs in a collection.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
retrieve(ItemId input) → Future<ItemOutput?>
Retrieves an item from the database.
inherited
retrieveMultiple(List<ItemId> ids) → Future<List<ItemOutput?>>
Retrieves multiple items from the database.
inherited
retrieveMultipleSync(List<ItemId> ids) → List<ItemOutput?>
Retrieves multiple items from the database.
inherited
retrieveSync(ItemId input) → ItemOutput?
Retrieves an item from the database.
inherited
toString() → String
A string representation of this object.
inherited
update(ItemWithId input) → Future<void>
Updates an existing item in the database.
override
updateSync(ItemWithId input) → void
Updates an existing item in the database.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited