qoq-cache
v0.0.2
Published
Cache middleware for qoq.
Downloads
1
Readme
qoq-cache
Cache middleware for qoq.
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