Tuesday 18 April 2017

ioredis and async/await

I inherited some crappy JS code that I have to optimize, by adding a Redis-based cache layer. So I have been toying with ioredis, which is a great lib.The whole codebase was written by people who have no experience with functional programming. So it's basically a billion functions that return values. All this is fine and dandy in a synchronous world, but here I come with asynchronous stuff.I can't afford to rewrite everything on Promises. So my best shot seems to be async/await to manage the execution flow around (asynchronous) redis queries. But after toying around for a few hours, I can't seem to manage to write a function that :"pauses" while Redis is queried"resumed" when Redis answersreturns the result it got from Redisoverall behaves in a synchronous waySeems to me it's the perfect use-case...but maybe I just don't async/await ?

Submitted April 18, 2017 at 01:37PM by captain_obvious_here

No comments:

Post a Comment