Vert.x is great, but one thing that os missing is ...
# vertx
d
Vert.x is great, but one thing that os missing is cache that expires older entries and can be reset... Or maybe I missed something?
j
what kind of cache are you referring to ? do you mean a data cache like an
AsyncMap
?
But if I use that, I'll have a cache for each verticle instance running... when I really want a global cache for all instances of that verticle
Or even something similar to Spring's caching facility, I guess it could be implemented on the SharedData in Vert.x somehow...
Also, it might be sufficient to have an LRU on SharedData...
j
I think that SharedData does not want to be a cache, however a cache component for Vert.x would be a great thing I think, it could be implemented by cache2k or ehcache
I think for the moment however we should be pragmatic and test how cache2k works with Vert.x and come up with examples / recommandations
perhaps you can try to use cache2k and make experiments to see how it goes ?
and we can see if that works well or not
d
@julienviet I probably will, but I still don't see what the problem would be with SharedData, it would allow cross-vertx instance cache...
j
to be honnest, the main issue I see is that if we start to make it like a cache, then we will need to have more and more caching features in it and it will gain in complexity + features and I thin kit's not the scope of vertx core
that's my main opinion
now I think that some people asked to have a TTL on SharedData
d
@julienviet I think TTL would probably cover alot of use cases... I don't want to requery the db for info that tons of requests commonly need, but it needs to expire periodically to be fresh...
j
actually AsyncMap has TTL
void put(K k, V v, long ttl, Handler<AsyncResult<Void>> completionHandler);
d
@julienviet Nice! I'll check it out (although the AsyncMap is a bit harder to work with... maybe a coroutine extension function will take care of that...) I guess another useful feature would be a limited space LRU, but maybe that's too much? Because, sometimes TTL with lots of requests for different types of info could fill up memory with cache data that might not always be reused... but TTL is already great! Why is TTL only in AsyncMap?
j
have you tried coroutines ?
LocalMap is not a cache and AsyncMap neither is
that's the point
otherwise it would be
io.vertx.cache
package
imho we should investigate how Vert.x works well with Cache2k
that's a real cache 🙂
and eventually comes with a Vert.x Cache facade to improve things
d
@julienviet I'm currently using your coroutine extension with my own extension function that I'll offer to the project when I get enough of them together..😉
j
great!
d
@julienviet Why do you think cache2k would not work with vert.x?
j
I think after 3.5 we should rework the current vertx lang integration and make it happen outside of Vert.x projects so it's easier to contribute specific kotlin extensions
d
Also it would be nice to turn all your delegate classes (like rx) into extension functions, it just adds complexity... and its not Kotlinish 🤓
@julienviet How would cache2k work through multiple verticle instances, is there a way to do this currently? Maybe putting the whole cache in a SharedData?
j
that's something to investigate
for Rx, we cannot make extension classes for Java
that's unfortunate