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
?
1 Answer
Reset to default 0The 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条)