redis for qoq based on ioredis.
yarn add qoq-redis
import { WebSlotManager, defineConfig } from 'qoq';
import { RedisSlot, RedisOptions } from 'qoq-redis';
const redisOptions = defineConfig<RedisOptions>({
...
});
const webSlots = WebSlotManager.use(new RedisSlot(redisOptions));
Then feel free to use in request or commands
import { createWebRouter } from 'qoq';
export const router = createWebRouter(webSlots);
router.get('/').action(async (ctx) => {
await ctx.redis.set('hello', 'world');
ctx.body = 'OK';
});
import { WebSlotManager, ConsoleSlotManager, defineConfig } from 'qoq';
import { Redis, RedisOptions } from 'qoq-redis';
+ import { CacheSlot } from 'qoq';
+ import { RedisCacheOptions } from 'qoq-redis';
const redisOptions = defineConfig<RedisOptions>({
...
});
+ const cacheOptions = defineConfig<RedisCacheOptions>({
+ engine: 'qoq-redis/RedisCache',
+ redisOptions: redisOptions,
+ });
const webSlots = WebSlotManager
.use(new RedisSlot(redisOptions))
+ .use(new CacheSlot(cacheOptions));
@see ioredis