qoq-cache

Cache middleware for qoq.

Usage no npm install needed!

<script type="module">
  import qoqCache from 'https://cdn.skypack.dev/qoq-cache';
</script>

README

qoq-cache

Cache middleware for qoq.

License GitHub Workflow Status (branch) Codecov

Installation

yarn add qoq-cache

Create middleware

import { WebSlotManager, createConfig } from 'qoq';
import { Cache, MemoryCacheOptions } from 'qoq-cache';

const cacheOptions = createConfig<MemoryCacheOptions>({
  slot: 'MemoryCache',
});

const webSlots = WebSlotManager.use(new Cache(cacheOptions));

Then feel free to use in routers

import { createWebRouter } from 'qoq';

export const router = createWebRouter({
  slots: webSlots,
});

router
  .get('/')
  .action(async (ctx) => {
    await ctx.cache.set('hello', 'world');
    ctx.send('OK');
  });

Built-in engines

  • FileCache
  • MemoryCache

Use cache by redis engine?

Of course, @see qoq-redis

Use cache by mysql engine?

Of course, @see qoq-sequelize