Updated Storage (markdown)

TheMode 2020-05-04 19:33:29 +02:00
parent 591adf601c
commit 9fea26e06c

@ -21,4 +21,26 @@ byte[] data;
...
storageFolder.set("test", data);
data = storageFolder.get("test");
```
## Integration with SerializableData
Most of the data that you will store will be in the form of SerializableData.
There are two kind of SerializableData that you would want to store:
1. A Data object which should not change but be unique and applied to multiple objects
2. A Data object linked to an element and which should be synchronized
For the first type you would need:
```java
// The data is gonna be retrieved, cloned and applied to the DataContainer specified
storageFolder.getAndCloneData(key, dataContainer);
```
And for the second:
```java
// The data is gonna be retrieved, applied to the DataContainer
// And the storage folder will cache it for further saving
storageFolder.getAndCacheData(key, dataContainer);
...
// Save all the cached SerializableData
storageFolder.saveCachedData();
```