nodejs redis setex
async function upsert(table, data) {
let key = table;
if (data && data.id) {
key = key + '_' + data.id;
}
client.setex(key, 10, JSON.stringify(data));
return true;
}
nodejs redis setex
async function upsert(table, data) {
let key = table;
if (data && data.id) {
key = key + '_' + data.id;
}
client.setex(key, 10, JSON.stringify(data));
return true;
}
redis nodejs
/* npm install redis */
const redis = require("redis");
const client = redis.createClient();
client.on("error", function(error) {
console.error(error);
});
client.set("key", "value", redis.print);
client.get("key", redis.print);
node-redis
// node-redis to promise, because node-redis not support promise
import bluebird from 'bluebird'
import { Commands, createClient } from 'redis'
const client = createClient({
host: process.env.REDIS_HOST,
port: parseInt(process.env.REDIS_PORT),
password: process.env.REDIS_PASSWORD
})
let redisCon: Commands<any>
;(async (redis) => {
const redisPromise = await bluebird.resolve<Commands<any>>(redis)
redisCon = redisPromise
})(client)
export { redisCon }
connect-redis github
yarn add redis connect-redis express-session
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us