Package org.ngengine.store
Class DataStore
java.lang.Object
org.ngengine.store.DataStore
A data store is key-value storage that can be used to store $
Savable
and serializable objects and
primitives to a persistent storage.
It uses VStore
internally and differentiates between cache and data stores, however the actual
implementation is platform dependent and will use whatever form of storage is the most appropriate and
efficient for the platform and the intended use case.
-
Constructor Summary
ConstructorsConstructorDescriptionDataStore
(String appName, AssetManager assetManager, String name, boolean isCache) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deletes a key from the store.boolean
Checks if a key exists in the store.org.ngengine.platform.VStore
list()
Clears the store, deleting all keys.<T> T
Reads a savable or serializable object or a primitive from the store.void
Fully writes and commits a savable or serializable object or a primitive.
-
Constructor Details
-
DataStore
-
-
Method Details
-
getVStore
public org.ngengine.platform.VStore getVStore() -
write
Fully writes and commits a savable or serializable object or a primitive.- Parameters:
key
- the key to store the object undervalue
- the object to store, must be aSavable
or serializable object- Throws:
IOException
-
read
Reads a savable or serializable object or a primitive from the store.- Parameters:
key
- the key to read the object from- Returns:
- the object read from the store, can be a
Savable
or a serializable object - Throws:
IOException
- if reading fails
-
exists
Checks if a key exists in the store.- Parameters:
key
- the key to check- Returns:
- true if the key exists, false otherwise
-
delete
Deletes a key from the store.- Parameters:
key
- the key to delete
-
list
Clears the store, deleting all keys.
-