function withCache(cache, fn) {
	const memory = new Map();
	// @ts-ignore
	return async (...args) => {
		const key = String(args[0]);
		if (memory.has(key)) return memory.get(key);
		const entry = await cache.get(key);
		if (entry.isCached) {
			const value = JSON.parse(entry.value);
			memory.set(key, value);
			return value;
		}
		const p = fn(...args);
		memory.set(key, p);
		const v = await p;
		memory.set(key, v);
		cache.set(key, JSON.stringify(v));
		return v;
	};
}
Memoize backed by layered in-memory & disk caches.
@template {function} T
@param {any} cache
@param {T} fn
@returns {((...rest: Parameters<T>) => ReturnType<T>)}