You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to watch for the expiration of data within a Quarkus Cache. When an entry expires and is ejected from cache, I'd like the key and value being ejected to be passed to a custom hook so that I may perform some action.
Use case: I have an upstream database that provides data to my service. Its caching options are much more simplistic than my Quarkus application's caching options. Via my Quarkus service I can tell that upstream service to cache data for me and I can set an expiration time and that's it. Basically an expire after write. I can also tell this external database to drop cached results. Unfortunately there's no way for me to trigger this external service to drop results without a scheduled method. It would be cool if I could cache a reference to the stored results and when my reference cache expires after access, I could trigger the remote service to drop its cache as well.
Implementation ideas
I'm not great at writing hooks and callbacks but here's a quick idea of how this could look based on what I know about Quarkus.
@CacheExpirationHook(cacheName="my-cache")
voidonMyCacheValueEjection(Stringkey, SomeTypevalue) {
// key and value are passed from the cache's triggered expiration event// tell remote service to drop cache// do some other things here
}
@CacheHook(cacheName="my-cache")
voidonMyCacheValueEjection(@ObservescacheEjectionEventejected) {
ejected.getKey(); // The key ejected from cacheejected.getValue(); // The value ejected from cache// tell remote service to drop cache// do some other things here
}
The text was updated successfully, but these errors were encountered:
Description
I'd like to watch for the expiration of data within a Quarkus Cache. When an entry expires and is ejected from cache, I'd like the key and value being ejected to be passed to a custom hook so that I may perform some action.
Use case: I have an upstream database that provides data to my service. Its caching options are much more simplistic than my Quarkus application's caching options. Via my Quarkus service I can tell that upstream service to cache data for me and I can set an expiration time and that's it. Basically an expire after write. I can also tell this external database to drop cached results. Unfortunately there's no way for me to trigger this external service to drop results without a scheduled method. It would be cool if I could cache a reference to the stored results and when my reference cache expires after access, I could trigger the remote service to drop its cache as well.
Implementation ideas
I'm not great at writing hooks and callbacks but here's a quick idea of how this could look based on what I know about Quarkus.
The text was updated successfully, but these errors were encountered: