4 ms·
Does node have something similar to how apcu is used with PHP? That is, an mmap based kv store so that if you choose to run more than one node process on a sin
by tyingq 7y ago
Does node have something similar to how apcu is used with PHP?
That is, an mmap based kv store so that if you choose to run more than one node process on a single server, it has a fast kv cache?
I'm aware you can use redis or similar, but a simple mmap kv store is simpler and faster for a single server use case.
- ddorian43 7y agoYou can use something like LMDB on every language.
- godot 7y agoI totally see what you mean, coming from a PHP world myself a few years ago. The key thing to note is that node.js (like many other languages including Java) starts a server process that basically does not stop until you explicitly restart it (or it crashes); unlike PHP where every request starts a brand new process on a clean slate (hence needing APCu to store a local memory cache per server). Meaning, what you can accomplish with APCu in PHP can be trivially accomplished by a simple Object in node.js (i.e. a map/hash), by virtue of having a require cache (hence every time you require'd the lib it returns the same instance of the object). If you want a simple open source lib to do exactly that for you and provide an easy to use API, you can use something like https://www.npmjs.com/package/tmp-cache https://www.npmjs.com/package/tmp-cache .
- tyingq 7y agoThe context is multiple node processes running on a single box, so a shared cache across processes has value for some use cases. I don't think the cache module you suggested would work in that case. I'm aware of the runtime model differences between node and PHP.