I have a need to cache (in memory) a bunch of fairly lengthy strings. Seems a shame to use memory unnecessarily, particularly when there is a memory quota imposed, so was wondering whether it's sensible to compress those strings before caching, and then decompress after fetching.
Seems like node.js has a built-in zlib module, and although that seems to be aimed more at file/stream compression, may be of use for simple string compression, e.g. from the docs:
var input = '.................................';
zlib.deflate(input, function(err, buffer) {
if (!err) {
console.log(buffer.toString('base64'));
}
});
Any thoughts? Any other libraries or utility functions available?