HiveCacheStorage class
Persistent disk-based cache storage implementation using Hive.
HiveCacheStorage stores each CacheEntry as a JSON string inside a
Hive Box<String>. This provides fast key-value persistence that survives
app restarts and works well on all Flutter-supported platforms.
Call init before performing any other operations to ensure the Hive backend is fully initialized and the box is open.
- Implemented types
Constructors
- HiveCacheStorage({String boxName = 'flutter_api_cache'})
-
Creates a new HiveCacheStorage with an optional
boxName.
Properties
- boxName → String
-
The Hive box name used for storage.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
length
→ Future<
int> -
The total number of entries currently stored in the Hive box.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sizeInBytes
→ Future<
int> -
The approximate total size of all cached data in bytes.
no setteroverride
Methods
-
clear(
) → Future< void> -
Removes all entries from the Hive box.
override
-
close(
) → Future< void> -
Closes the Hive box and releases any held resources.
override
-
containsKey(
String key) → Future< bool> -
Returns
trueif an entry with the givenkeyexists in the box.override -
get(
String key) → Future< CacheEntry?> -
Retrieves a cached entry by its
key.override -
getAllKeys(
) → Future< List< String> > -
Returns a list of all cache keys currently stored in the Hive box.
override
-
init(
) → Future< void> -
Initializes the Hive backend and opens the storage box.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
put(
String key, CacheEntry entry) → Future< void> -
Stores a CacheEntry with the given
key.override -
remove(
String key) → Future< void> -
Removes the cache entry associated with
key.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited