Redis keys async wrapper
npm install --save redis-async-wrapper
Only a part of redis commands added in this wrapper till now.
const dal = require('redis-async-wrapper')
// init with options
dal.init({url: "redis://host:port", keyPrefix: "app"})
// define keys conventions
const Templates = {
user: "user:%s:%s" // user:userId:type
}
// define model
const User = new dal.Redis_Hash({tpl:Templates.user})
User.save = async (id, type, infoObject) => {
await User.hmset([id, type], infoObject)
const user = await User.hgetall([id, type])
console.log(`user ${user.name} is saved`)
}
User.save(1, 1, {name: "stefan"})
Glad to get contributors to this library, contact me at stefanliu@outlook.com !