set<T> method
Set data in Cache
key
will be used to fetch data back from cache.
data
which needs to be stored, it will be converted to Hive Format,
based on CacheTypeRegistry
Implementation
set<T>(String key, T data, {Duration? expiryDuration}) async {
final resolver = this._getResolver<T>();
final currentEpoch = DateTime.now();
final item = ItemCache(
key: key,
expireOn: currentEpoch.add(expiryDuration ?? policy.cacheDuration),
data: _generateHiveData(resolver.type, data),
lastValidated: currentEpoch,
);
_box.put(_generateHiveKey(key), item);
}