We are considering implementing SpringBoot Cache.The cache provider becomes Redis.
@ Cacheable caches the results of the method with key:value.
As a business requirement, it is not only necessary to cache results, but also to store keys in hset.
Therefore, is there a means to execute business logic after caching the results?
I looked it up and it doesn't look like CacheResolver.The sources are as follows:
@Caching(
cacheable={@Cacheable(value="hello", key="#myUser.name+#root.methodName")},
put={@CachePut(value="hello", key="#myUser.name+#root.methodName", condition="#myUser.age==12")},
event={@CacheEvict(value="hello", key="#myUser.name+#root.methodName", allEntries=false, condition="#myUser.age==99")}
)
publicList<Map<String,Object>>getResultList(MyUser myUser){
Map<String, Object>resultMap1 = new HashMap<>();
resultMap1.put("result", "result10");
Map<String, Object>resultMap2 = new HashMap<>();
resultMap2.put("result", "result20");
System.out.println("MyRedisService.getResultList executed!input:"+myUser.toString());
return List.of (resultMap1, resultMap2);
}
I found a way.
Step 1: Expand RedisCache.Override the get
method and add business logic.
Step 2: Expand RedisCacheManager.Override the createRedisCache
method and utilize RedisCache extended to Step 1.
Step 3: Create the RedisCacheManager extended in Step 2 as Bean in the configuration class.
925 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
615 GDB gets version error when attempting to debug with the Presense SDK (IDE)
574 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.