qoq-cache
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i qoq-cache

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

20 kB

Total Files

18

Last publish

Collaborators

  • fwh1990