Skip to content
File

Blob: samples/memory-cache/worker.js

javascript17 lines
1// Copyright (c) 2017-2023 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4 
5export default {
6 async fetch(req, env) {
7 const cached = await env.CACHE.read("hello", async (key) => {
8 return {
9 value: 'World',
10 expiration: Date.now() + 10000,
11 };
12 });
13 
14 return new Response(`Hello ${cached}\n`);
15 }
16};