0.0.2 • Published 3 years ago

qoq-cache v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

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