Created
March 17, 2018 18:59
-
-
Save vladzadvorny/06fec0949a8a31b69e21419e0110f3ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis from 'redis'; | |
import { promisify } from 'util'; | |
import { redisHost as host, redisPort as port } from './config'; | |
const client = redis.createClient({ host, port }); | |
client.on('ready', () => console.log('Redis is ready')); | |
client.on('error', err => console.log(`Radis ${err}`)); | |
export const redisGet = promisify(client.get).bind(client); | |
export const redisSet = promisify(client.set).bind(client); | |
/// | |
import { redisSet, redisGet } from '../redis'; | |
const myFunc = async () => { | |
const res = await redisSet('123', 'hello', 'EX', 20); | |
console.log(res); | |
const res2 = await redisGet('122'); | |
console.log(res2); | |
}; | |
myFunc(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment