Closed rskvazh closed 2 weeks ago
I think CacheableMemory is great for my task and working ok, but stats unavailable for it.
@rskvazh - thanks so much for this post and just recently we added the ability to bypass the serialization (great use case for in-memory caching). I have not fully tested this but this should work if you are using the latest Keyv v5.2.1
import Keyv from 'keyv';
import {KeyvCacheableMemory, Cacheable} from 'cacheable';
const primary = new Keyv({ store: new KeyvCacheableMemory });
primary.serialize = undefined;
primary.deserialize = undefined;
const cache = new Cacheable({ primary });
Again, I have not tried it out yet but I believe this would work. If not, the older way is to use your own custom serialization on Keyv that supports BigInt. You can read about it here: https://keyv.org/docs/keyv/#custom-serializers
Thank you! 🙏 Will try it soon.
Let me know how it goes and I’m happy to figure out how to help!
Yeap, its worked! Thank you.
Describe the bug I cannot store objects with BigInt values. I think this is overhead if I would use serialize (superjson, devalue...) for in-memory cache. Primary store of Cacheable serializes data.
I tried
new Cacheable({ primary: new KeyvCacheableMemory() })
, but it not helps because it wraps KeyvCacheableMemory with Keyv.How To Reproduce (best to provide workable code or tests!)