File
Blob: samples/memory-cache/worker.js
| 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 | |
| 5 | export 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 | }; |