-
Notifications
You must be signed in to change notification settings - Fork 3.4k
The LocalResponseCacheGatewayFilterFactory is creating a new CacheManager for each Filter #3025
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
Comments
That's intentional. You have two types of Cache for LocalResponseCache
|
I see the point of having an independent cache for each route, but why is it needed to instantiate a new cache-manager for each route? If there are e.g. 5 routes with LocalResponseCache fiter then it will result in 5 cache-managers each having 1 cache. With that solution it is impossible to customize the cache manager. |
I think because |
I doubt that setting |
But it called in Bean method:
|
That is what I'm saying. The Line 75 in eb098a7
The cacheManager should be reused instead of creating a new instance for each route. |
Yes you're right, It's like anti-pattern! |
Same question from my side, why would you create a separate cache manager for each route. A workaround that i have done is wrapping the filter inside another component and inject my cache manager myself:
The cache configuration looks like the following:
|
I am also facing this issue. Additionally, the cache managers created in LocalResponseCacheGatewayFilterFactory are not visible in '/actuator/caches.' As I wanted the option to manually invalidate some of these caches from time to time, I ended up with a custom re-implementation of LocalResponseCacheGatewayFilterFactory. I don't know if there was a better option to achieve this. |
The properties are per cache manager. If you can describe how to do it without a cache manager per route, we'd be happy to work on it. |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
The properties could be set per To instantiate a cache manager for each |
All the properties are set on Caffeine, not the cache manager. Can you show me how you would do it per cache? Lines 95 to 107 in 7e4bb5c
See #3145 for a more generic solution beyond caffeine. |
After looking, it looks like |
Thanks, I wasn't aware of this chsmge! |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
The LocalResponseCacheGatewayFilterFactory is not using the "gatewayCacheManger" bean, but always creating a new instance.
Is this a bug or correct by design?
spring-cloud-gateway/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/filter/factory/cache/LocalResponseCacheGatewayFilterFactory.java
Line 75 in eb098a7
The text was updated successfully, but these errors were encountered: