IO
backend.IO (Class)
Implements: spec.IO
Clay backend implementation for persistent key-value storage.
This class provides cross-platform persistent storage with different implementations based on the target platform:
- Desktop (sys + SQLite): Uses SQLite database for efficient storage
- Desktop (sys without SQLite): Falls back to individual files
- Web: Uses browser localStorage API
Key features:
- All data is encoded with MD5 hashing for integrity verification
- Keys are hashed to avoid filesystem issues with special characters
- Supports importing initial SQLite database from assets
- Thread-safe on platforms that support it
The SQLite implementation allows importing a pre-populated database from assets on first run, useful for shipping default data.
See: spec.IO The interface this class implements, ceramic.PersistentData For the high-level storage API
Instance Members
File-based implementation of saveString for sys targets without SQLite. Stores each key-value pair as a separate file in the storage directory.
Name | Type |
---|---|
key |
String |
str |
String |
Returns |
---|
Bool |
Name | Type |
---|---|
key |
String |
str |
String |
Returns |
---|
Bool |
Name | Type |
---|---|
key |
String |
Returns |
---|
String |
Private Members
Initializes the key-value storage backend if needed. Called by the main backend during initialization.