insert method
Inserts cacheObject
into the repository
Implementation
@override
Future<CacheObject> insert(
CacheObject cacheObject, {
bool setTouchedToNow = true,
}) async {
if (cacheObject.id != null) {
throw ArgumentError("Inserted objects shouldn't have an existing id.");
}
final keys = _jsonCache.keys;
final lastId = keys.isEmpty ? 0 : keys.reduce(max);
final id = lastId + 1;
cacheObject = cacheObject.copyWith(id: id);
return _put(cacheObject, setTouchedToNow);
}