Hacker News new | past | comments | ask | show | jobs | submit login

But what does it mean for a promise to be in the cache? If you're using an external cache, like redis or memcached, you can't just put a JavaScript promise in there and expect everything to work. Neither of those services understands what it means for the promise to resolve so that all the clients waiting on it can continue.

At best you could serialize the promise and then have everyone who was waiting on it poll the cache to see if the promise was resolved yet, but that is pretty inefficient.

You probably want another layer in there that handles the conversion of a JavaScript promise to something that can be awaited on from your cache, like a redis pub/sub. Then in JavaScript land your services just await on a promise as normal but under the covers your service is doing something else which is specific to the cache you're using.




I don't think they are using an external cache.


even if you have 1000 servers that all have a local promise you may still be helping the backend service by reducing 10000000 requests to 1000.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: