HiveAdapter class

A concrete implementation of CacheAdapter that uses the Hive NoSQL database for storage.

Example:

// Initialize the hive adapter
final adapter = HiveAdapter(boxName: 'myBox');

// Store a value
await adapter.put('myKey', CacheItem<String>(value: 'myValue', expiry: DateTime.now().add(Duration(days: 1))));

// Retrieve a value
final item = await adapter.get('myKey');
print(item?.value);
Implemented types

Constructors

HiveAdapter(TypeAdapterRegistry typeAdapterRegistry, {String? boxName, bool enableEncryption = false, String? encryptionKey})
Creates a new instance of HiveAdapter.

Properties

enableEncryption bool
Indicates if encryption is enabled for this 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
typeAdapterRegistry TypeAdapterRegistry
final

Methods

clear() Future<void>
Clears all data from the cache.
override
containsKey(String key) Future<bool>
Checks if the cache contains a value associated with the given key.
override
containsKeys(List<String> keys) Future<Map<String, bool>>
Checks if the cache contains values associated with all the given keys.
override
delete(String key) Future<void>
Deletes the value associated with the given key.
override
deleteAll(List<String> keys) Future<void>
Deletes multiple values associated with the given keys.
override
get(String key) Future<CacheItem?>
Retrieves the CacheItem associated with the given key.
override
getAll(List<String> keys) Future<Map<String, CacheItem>>
Retrieves multiple CacheItems associated with the given keys.
override
getKeys({int? limit, int? offset}) Future<List<String>>
Returns a list of all keys in the cache.
override
init() Future<void>
Initializes the adapter by opening the Hive box. This method must be called before using any other methods of this adapter.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
put(String key, CacheItem value) Future<void>
Stores a value in the cache with the given key.
override
putAll(Map<String, CacheItem> entries) Future<void>
Stores multiple values in the cache with the given keys.
override
toString() String
A string representation of this object.
inherited

Operators

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