edge-runtime
edge-runtime copied to clipboard
Primitives: Implement `Cache` as `CacheStorage` interfaces
The CacheStorage is holding all the
A CacheStorage
object represents a name to cache map of its associated global object's:
self.caches // CacheStorage {}
self.caches instanceof CacheStorage // true
You can create a new Cache
namespace there, and it will be an instance:
const cache = await caches.open('my_cache')
cache instanceof Cache // true
Additionally, CF Workers exposes a default
single global cache object:
const cache = caches.default
cache instanceof Cache
This cache is a bit special: Since the spec actually doesn't provide any way to manipulate the cache that backs fetch(), if you put something into it, then fetch() will match that thing.