-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Support for Caching List Results in Quarks Redis Cache #41301
Comments
/cc @Ladicek (redis), @cescoffier (redis), @gwenneg (cache), @machi1990 (redis) |
Generic types in general such as Optionals, collections, etc. are not supported. It'd be a great addition. |
The type detection is done at build time, not at runtime. Passing generic types will require a bit of work. |
I see. Could the mechanism Caffeine uses be reused here? |
No, because Caffeine does not need serialization/deserialization (it's all local). Here, the data must be serialized to be written into Redis and deserialized when retrieved. |
I would also need this feature. We have a couple of expensive endpoints which return lists of items and we want to cache. |
I think workaround would be to use your own custom List implementation like: MyList implements List |
We solved the problem by using wrapper classes around our lists and register them for reflection ( with the annotation @RegisterForReflection). With that solution the redis client automatically uses the JSON Codec for serialization/deserialization. Works quite well but the downside is that we have to create a wrapper class for every type we like to cache as a list. |
Yes, that approach works. |
We actually have solved that (mostly? I guess there are a few corner cases, but nothing major) in ArC, where we have code that takes Jandex |
That would definitely be a big step forward. Then we have to see how we can use this type with Jackson TypeReference I think. |
I'm no expert on the Quarkus Redis client, but it seems that's already been taken care of? See |
I think the only difficulty is to pass the parameterized type to the JsonCodec. From there Jackson should be able to do the serialization/deserialization. At the moment the class/type name is stored as a config at deployment time and later used in the RedisCacheImpl to load the class by using the class loader of the current thread (see io.quarkus.cache.redis.runtime.RedisCacheImpl#loadClass). This has to be adapted in order to work for parameterized types as well. |
OK, thanks, so there are 2 actual problems:
Nothing insurmountable, just more work than I expected. The first problem requires parsing the configuration string, the second requires either adding support for transferring types to recorders, or a complete rewrite to custom bytecode generation. |
|
Description
Currently, the Quarkus Redis Cache implementation does not support caching methods that return a list or a collection of objects. For example, if we use caching as shown in the example below, Quarkus complains that it cannot determine the value type of the cache.
In many applications, methods that return a list of objects are common. Therefore i suggest a mechanism such that the Quarkus Redis Cache implementation can infer the type correctly and that the entire list and its contents can be serialized and deserialized correctly when stored in and retrieved from Redis.
Implementation ideas
No response
The text was updated successfully, but these errors were encountered: