Async Redis

node v9.11.2
version: master
endpointsharetweet
const asyncRedis = require("async-redis"); const myCache = asyncRedis.createClient(); myCache.on("error", function(err) { console.log("Error " + err); }); const asyncBlock = async() => { await myCache.set("k1", "val1"); const value = await myCache.get("k1"); console.log("val2",value); }; var setValue = async(key, value) => { await myCache.set(key, value); }; var getValue = async(key) => { let val = await myCache.get(key); return val; }; asyncBlock(); // working setValue("aa", "bb"); // but this isn't console.log("val", getValue("aa"));//but this isn't
Loading…

no comments

    sign in to comment