spring boot - Does Redis support springframework @Cacheable(sync = true)? - Stack Overflow

I have multiple threads using a service which is annotated with @Cacheable(cacheNames = "myName&qu

I have multiple threads using a service which is annotated with @Cacheable(cacheNames = "myName", sync = true, keyGenerator = "myGenerator"). My understanding is the sync = true should cause the other threads to use the cached value from the first thread as long as the keyGenerator is the same value. My issue is both threads which call the service execute the service instead of one of them using the cached value even though the keyGenerator is the same. The docs say sync = true will only work if it is supported by the caching provider. I am using redis. I can't find any information on whether redis supports it. Does anyone know if redis supports sync = true?

I have multiple threads using a service which is annotated with @Cacheable(cacheNames = "myName", sync = true, keyGenerator = "myGenerator"). My understanding is the sync = true should cause the other threads to use the cached value from the first thread as long as the keyGenerator is the same value. My issue is both threads which call the service execute the service instead of one of them using the cached value even though the keyGenerator is the same. The docs say sync = true will only work if it is supported by the caching provider. I am using redis. I can't find any information on whether redis supports it. Does anyone know if redis supports sync = true?

Share Improve this question asked Mar 24 at 22:16 ponder275ponder275 9352 gold badges14 silver badges37 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The sync flag is only considered for a single local cache. As per Javadoc, the sync flag is a hint for the cache provider that may or may not synchronize.
Please check this thread:
https://github/spring-projects/spring-data-redis/issues/1670?utm_source=chatgpt

Documentation:
This is an optional feature, and your favorite cache library may not support it. All CacheManager implementations provided by the core framework support it. See the documentation of your cache provider for more details.
https://docs.spring.io/spring-framework/reference/integration/cache/annotations.html

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744225987a4564007.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信