{"repo":"hansottowirtz/cloudflare-workers-cache","free":true,"listed":false,"github":"https://github.com/hansottowirtz/cloudflare-workers-cache","clone":"git clone https://github.com/hansottowirtz/cloudflare-workers-cache.git","description":"`unstable_cache` from Next.js for Cloudflare Workers","language":"TypeScript","stars":11,"topics":["cache","cloudflare-cache","cloudflare-workers","kv-store","nextjs"],"license":null,"category":"saas-starters-boilerplates","readme_excerpt":"unstable cache from Next.js for Cloudflare Workers Cache any JSON-serializable result from an async function. It uses the same API as unstable cache from Next.js. - Simple wrapper function over the Cloudflare Workers Cache API. - Supports time-based and tag-based cache revalidation. - Stores tag revalidation data in a KV store. - No need for a Cloudflare Enterprise account for tag revalidation. Installation Setup First, create a kv namespace: Then, adjust your wrangler.toml : Usage See example-app/src/index.ts for a fully working example. API cache(fn, keyParts, options) Cache the result of an async function. Same API as unstable cache from Next.js. - fn : The async function to cache. - keyParts : The combination of the function arguments and keyParts create the cache key. - options : - tags : Tags which can be used in revalidateTag . - revalidate : Time in seconds after which the cache should be revalidated. revalidateTag(tag) Revalidate all cache entries with the given tag. Revalidation occurs on the next function call. provideCacheToFetch(cacheConfig, handler) Wrap a fetch handler with the cache configuration. Alternatively, you can use provideWaitUntil , provideObjectCache , provideCacheTagStore to set async contexts separately. See src/wrap-fetch.ts. createCfCacheObjectCache(cache) Create an object cache using the Cloudflare Cache. createCfKvCacheTagStore(kvNamespace) Create a cache tag store using a Cloudflare KV store. Write custom cache stores By default, the object c","default_branch":null,"files":null,"tree":[],"storefront":"/r/hansottowirtz","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/hansottowirtz/cloudflare-workers-cache/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}