json feature
I think it would be a good idea to add an option to toggle a json mode, to use the json type in redis instead of string
Can you explain why?
because im using ft.search and json.get tu search and get part of json object stored with bentocache, and I think this shouldn't be to difficult to add the option here directly if it help other people
I'll add my 2 cents - de/serialization is known to be expensive, plus it unexpectedly transforms values.
A common use-case is to cache database models. Let's say your article model has createdAt attribute, hydrated by your ORM to Date object. You wrap the fetch to bentocache, and your GraphQL engine starts complaining, because the Date scalar expects Date instance, not string (which is the result of de/serialization).
This is especially confusing when using just L1 inmemory cache, which doesn't need serialization at all. Having an option to provide a no-op serializer, or better, to use best matching native methods at the storage driver level, would (massively, I believe) increase throughput/rps for L1-only scenarios, and reduce integration hiccups, such as the Date-string conversion.
I'll add my 2 cents - de/serialization is known to be expensive, plus it unexpectedly transforms values.
A common use-case is to cache database models. Let's say your
articlemodel hascreatedAtattribute, hydrated by your ORM toDateobject. You wrap the fetch to bentocache, and your GraphQL engine starts complaining, because theDatescalar expectsDateinstance, notstring(which is the result of de/serialization).This is especially confusing when using just L1 inmemory cache, which doesn't need serialization at all. Having an option to provide a no-op serializer, or better, to use best matching native methods at the storage driver level, would (massively, I believe) increase throughput/rps for L1-only scenarios, and reduce integration hiccups, such as the Date-string conversion.
Sorry I think I did'nt really understood what you meant. Because all these problems will still exist if you use RedisJSON
To come back to the main issue: I think the ideal would just be to have a RedisJSON driver rather than modifying the original redis driver. Maybe a community package, or even a PR that add that driver could do the job. Would you be willing to contribute that @yovanoc ? Should be pretty easy to do if your take a look at other drivers : https://github.com/Julien-R44/bentocache/blob/main/packages/bentocache/src/drivers/redis.ts
IORedis doesn't support JSON out of the box, but I created myself a wrapper around it, if I can add that too (only for this new redis json driver), I can try to open a PR !
Because all these problems will still exist if you use RedisJSON
@Julien-R44 right, I'm sorry for the confusion and for "hijacking" the issue with a different topic.
Oh okay, no worries. Feel free to open another issue about this issue if needed
Closing the issue since I don't have the bandwith to work on it right now. If the feature is still needed feel free to reopen it