Creates a new FileStorage instance that stores data in the specified folder.
The absolute or relative path to the folder where the state.json file will be stored
Deletes store items from the filesystem storage.
Array of keys to delete from storage
Promise that resolves when the delete operation completes
Reads store items from the filesystem storage.
Array of keys to read from storage
Promise resolving to an object containing the requested items (keys that don't exist are omitted)
Writes store items to the filesystem storage.
Object containing key-value pairs to write to storage
Promise that resolves when the write operation completes
This method updates both the in-memory cache and writes the entire state to the state.json file. The file is written with pretty-printing (2-space indentation) for better readability during development and debugging.
This implementation does not support eTag-based optimistic concurrency control. Any eTag values in the changes object are ignored.
A file-based storage implementation that persists data to the local filesystem.
Remarks
FileStorage stores all data in a single JSON file named 'state.json' within a specified folder. This implementation is suitable for development scenarios, local testing, and single-instance deployments where shared state across multiple instances is not required.
The storage format is a simple key-value JSON object where keys are strings and values can be any JSON-serializable data. All operations are synchronous file I/O operations wrapped in Promise interfaces to match the Storage contract.
Warning
This implementation does not provide:
For production scenarios requiring these features, consider using database-backed storage implementations instead.
Example