I come from the Java world, and there are many implementations of (local) caches in memory. Moreover, there are SoftReference and WeakReference in the Java world, and they, by definition, are ideal for implementing the cache.
I know that JavaScript has nothing of the kind, so I wonder if it is possible to have some kind of cache function that will remove / free (all) cached objects if there is "low memory pressure". Until now, I knew for lru-cache the module, but its implementation contains objects up to a certain amount / size, which is nice, but not good enough, because, naturally, you'd expect from the cache to free objects if there is not enough memory.
Is it even possible to get some kind of event in NodeJS from the system when the process is running on low memory?
Or maybe some kind of library that can raise an event, for example:
var cmmm = require('cool_memory_management_module'); cmmm.on('low_memory', function(){
So far I have found npm memwatch and npm use , but still have not been able to combine all of these parts.
Tomo
source share