edge-runtime icon indicating copy to clipboard operation
edge-runtime copied to clipboard

Primitives: Implement `Cache` as `CacheStorage` interfaces

Open Kikobeats opened this issue 2 years ago • 0 comments

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.

Kikobeats avatar Jul 26 '22 13:07 Kikobeats