MustangStore class
MustangStore is an in-memory key-value object database.
- Objects are saved to the store using it's type as the key
- Types should not be null. E.g. User is a valid type but not User?
- If an object exists, existing object will be replaced
Constructors
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- persistent → bool
-
Returns persistence status of the store
no setter
Static Methods
-
config(
{bool isPersistent = false, String? storeName}) → Future< void> - Configures persistence for the store
-
configPersistence(
String storeName, String? storeLocation) → Future< void> -
Creates a directory on the disk to save stringified objects.
storeLocation
is optional for Web. Persistence also enables cache behind the scenes. -
delete<
T> () → Future< void> -
Removes an object of type
T
from memory and from the persistent store -
deleteFromStore<
T> () → Future< void> -
Removes an object of type
T
only from memory Note: This API is only for unit testing -
deleteObjects(
{required List< String> preserveModels}) → Future<void> - Deletes all objects except the ones passed in to the the preserveModels argument
-
deletePersistedState(
List< String> deleteModels) → Future<void> - If persistence is enabled, delete specified persisted models
-
get<
T> () → T? -
Looks up for an object of type
T
. Returns null if the object is not found. -
getPersistedObject(
String modelName) → Future< String?> - Returns the stringified model from the persistence store. Returns null if the model does not exist.
-
getState(
{required String name}) → MustangState? -
initPersistence(
String? storeLocation) → Future< void> -
Creates a directory on the disk to save stringified objects.
storeLocation
is optional for Web. Persistence also enables cache behind the scenes. -
nuke(
) → Future< void> - Delete all objects from the store
-
persistObject(
String key, String value) → Future< void> - If persistence is enabled, it saves stringified object to the disk.
-
restoreState(
void callback(void update< T>(T t), String modelName, String jsonStr), List<String> serializerNames) → Future<void> - Allows the caller to deserialize and load objects into the Mustang Store. Note: Deserialization has to be done by the caller. This method only returns serialized objects and their types.
-
update<
T> (T t) → void -
Saves an object
t
of typeT
. If the object of the same type exists, it will be replaced. -
update2<
T, S> (T t, S s) → void -
Saves objects
t
,s
of typeT
andS
respectively. If any object of the same type exists, it will be replaced. -
update3<
T, S, U> (T t, S s, U u) → void -
Saves objects
t
,s
,u
of typeT
,S
andU
respectively. If an object of the same type exists, it will be replaced. -
update4<
T, S, U, V> (T t, S s, U u, V v) → void -
Saves objects
t
,s
,u
,v
of typeT
,S
,U
andV
respectively. If an object of the same type exists, it will be replaced.