Class DataStore

java.lang.Object
org.ngengine.store.DataStore

public class DataStore extends Object
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 Details

  • Method Details

    • getVStore

      public org.ngengine.platform.VStore getVStore()
    • write

      public void write(String key, Object value) throws IOException
      Fully writes and commits a savable or serializable object or a primitive.
      Parameters:
      key - the key to store the object under
      value - the object to store, must be a Savable or serializable object
      Throws:
      IOException
    • read

      public <T> T read(String key) throws IOException
      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

      public boolean exists(String key)
      Checks if a key exists in the store.
      Parameters:
      key - the key to check
      Returns:
      true if the key exists, false otherwise
    • delete

      public void delete(String key)
      Deletes a key from the store.
      Parameters:
      key - the key to delete
    • list

      public List<String> list()
      Clears the store, deleting all keys.