Closed mmillies closed 2 weeks ago
@mmillies - thanks for sending this out and yes we know that this is an issue and we plan to resolve it soon by adding in a better way to handle in-memory solutions. We are currently working on thew new @keyv/redis
adapter but in the future will be doing the following:
KeyvGenericAdapter
- We will be introducing a generic adapter that will take any Map compatible in-memory
and wrap it so Keyv doesn't do the heavy lifting and will just pass back to the storage adapter the object. This will help a ton and we plan to have this out by end of year. Updates to Compression and Serialization
- We will be updating compression to only do that work and not the serialization part. This will help with how we handle serialization and make it so for in-memory
such as the KeyvGenericAdapter
it can just not use it. Hope this helps and appreciate that you already figured out a work around for things like this. Also, if you just want to do in-memory
I would highly suggest using CacheableMemory which is the next generation caching library. 🎉
yep, using your CacheableMemory package at the moment 🥳 . We're a recent migration from the old cache-manager (pre-v4) up to ya'lls latest.
I'm just troubleshooting some performance stuff, hoping the serialization tweak gets me past the finish line.
And thanks again for doing all this. Pretty neat stuff for sure. 👍
(And thanks for supporting both module types. made the upgrade easier)
I guess this is probably more an investigative question.
Is your feature request related to a problem? Please describe.
I was analyzing performance metrics in an application that uses this library and noticed the serialization/deserialization routines were getting executed for an in-memory store without compression.
I was surprised. Is there a reason the value must be serialized when storing in memory, specifically when compression is NOT configured?
https://github.com/jaredwray/keyv/blob/main/packages/keyv/src/index.ts#L317
Describe the solution you'd like
I see areas where there is an
if-statement
checking if compression is turned on before doing the deserialization routines (which is what I was expecting).https://github.com/jaredwray/keyv/blob/main/packages/keyv/src/index.ts#L220
Am I missing something in the framework that causes serialization of the values to be a requirement when compression is NOT enabled?
To be clear, I'm currently testing "turning off" serialization by overriding the serialization/deserialization functions with no-op functions. (thank y'all for putting those configuration overrides in to make this easy to do) So I'm not actively worried about this. I am just curious if I am missing something.
I can also throw a PR out there for patching if this is deemed as something that should be patched.