BloomJsonStorage class

JSON object storage with optional TTL expiration.

Encapsulates serialization and deserialization of typed JSON records with automatic expiration pruning.

Example:

final jsonStorage = BloomJsonStorage(FileStorageAdapter());
await jsonStorage.set('user_profile', {'name': 'Alice', 'role': 'admin'}, ttl: const Duration(hours: 1));
final profile = await jsonStorage.get<Map<String, dynamic>>('user_profile');

Constructors

BloomJsonStorage([BloomStorageAdapter? adapter])
Creates a BloomJsonStorage instance with an optional adapter (defaults to FileStorageAdapter).

Properties

adapter BloomStorageAdapter
The underlying key-value storage adapter.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clear() Future<void>
Clears all stored data in the underlying adapter.
contains(String key) Future<bool>
Checks if a key exists in storage.
delete(String key) Future<void>
Deletes a key from storage.
get<T>(String key) Future<T?>
Retrieves and decodes a stored JSON object. Returns null if absent or expired.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readJson<T>(String key) Future<T?>
Alias for get to retrieve a stored JSON object.
set<T>(String key, T value, {Duration? ttl, Duration? expiresIn}) Future<void>
Stores a JSON-encodable value with optional ttl or expiresIn duration.
toString() String
A string representation of this object.
inherited
writeJson<T>(String key, T value, {Duration? ttl, Duration? expiresIn}) Future<void>
Alias for set to store a JSON object.

Operators

operator ==(Object other) bool
The equality operator.
inherited