Skip to content

Instantly share code, notes, and snippets.

@vladzadvorny
Created March 17, 2018 18:59
Show Gist options
  • Save vladzadvorny/06fec0949a8a31b69e21419e0110f3ff to your computer and use it in GitHub Desktop.
Save vladzadvorny/06fec0949a8a31b69e21419e0110f3ff to your computer and use it in GitHub Desktop.
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