yeps-redis
v1.0.1
Published
YEPS promise based redis client
Downloads
5
Maintainers
Readme
YEPS ioredis
YEPS Promise based redis client
How to install
npm i -S yeps-redis
How to use
Config
config/default.json
{
"redis": {
"host": "127.0.0.1",
"port": 6379
}
}
Middleware
const App = require('yeps');
const Router = require('yeps-router');
const redis = require('yeps-redis');
const error = require('yeps-error');
const logger = require('yeps-logger');
const server = require('yeps-server');
const app = new App();
const router = new Router();
app.all([
error(),
logger(),
redis(),
]);
app.then(async ctx => {
await ctx.redis.set('data', 'test');
const data = await ctx.redis.get('data');
});
router.get('/url').then(async ctx => {
await ctx.redis.set('data', 'test');
const data = await ctx.redis.get('data');
ctx.res.statusCode = 200;
ctx.res.end(data);
});
app.then(router.resolve());
server.createHttpServer(app);
Module
const redis = require('yeps-redis/redis');
async () => {
await redis.set('test', 'test');
const data = await redis.get('test');
}