-
Notifications
You must be signed in to change notification settings - Fork 1
π¦ Storage
The Storage module provides a persistent key-value storage system built on top of the Json module. It allows storing and retrieving JSON objects, strings, and lists across sessions by saving data into files located in the ./Storage/ directory.
The system automatically manages file rotation with size limits, keeping an index file (index.json) to map keys to file identifiers. This ensures efficient storage even for large datasets.
The module revolves around the singleton class STORAGE.
It provides methods to insert, update, retrieve, and delete data. Internally, data is distributed across multiple JSON files, with an index file maintaining the mapping between keys and files.
The module supports strings, JSON objects, lists of strings, and lists of JSON objects.
void SetJson(String name, Json data)Stores a JSON object under the given key.
Parameters:
-
name: Key name. -
data: JSON object to store.
void SetString(String name, String data)Stores a string under the given key.
Parameters:
-
name: Key name. -
data: String value to store.
void SetStringList(String name, List<String> data)Stores a list of strings under the given key.
Parameters:
-
name: Key name. -
data: List of strings to store.
void SetJsonList(String name, List<Json> data)Stores a list of JSON objects under the given key.
Parameters:
-
name: Key name. -
data: List of JSON objects to store.
Json GetJson(String name)Retrieves a JSON object by key.
Parameters:
-
name: Key name.
Returns: The stored JSON object.
String GetString(String name)Retrieves a string by key.
Parameters:
-
name: Key name.
Returns: The stored string.
List<String> GetStringList(String name)Retrieves a list of strings by key.
Parameters:
-
name: Key name.
Returns: The stored list of strings.
List<Json> GetJsonList(String name)Retrieves a list of JSON objects by key.
Parameters:
-
name: Key name.
Returns: The stored list of JSON objects.
void Delete(String name)Removes a value from storage.
Parameters:
-
name: Key name.
Notes: If the key does not exist, no action is taken.
void Clear()Removes all stored data, deletes all associated JSON files, and resets the index file.