cache

The cache utility can only be used on Cloudflare Workers at the moment.

Before using it, you should set a unique name for your cache:

const app = new cheetah({
  cache: {
    name: 'example.com'
  }
})

set()

c.cache.set(key, value, options)
app.get('/', c => {
  await c.cache.set('foo', 'bar', { maxAge: 600 }) // expires after 10 minutes

  await c.cache.set('foo', 'bar') // expires after 5 minutes
})

get()

c.cache.get(key, type)
app.get('/', c => {
  await c.cache.get('foo', 'json')
})

has()

c.cache.has(key)
app.get('/', c => {
  await c.cache.has('foo')
})

delete()

c.cache.delete(key)
app.get('/', c => {
  await c.cache.delete('foo')
})