0
    @Bean
    public CacheManager cacheManager() {
        CaffeineCacheManager caffeineCacheManager = new CaffeineCacheManager();
        caffeineCacheManager.getCache("addresses");
        caffeineCacheManager.setCacheLoader(cacheLoader());
        caffeineCacheManager.setCaffeine(caffeineConfig());
        return caffeineCacheManager;
    }
        Caffeine caffeineConfig() {
        return Caffeine.newBuilder().expireAfterAccess(Duration.ofSeconds(5));
    }

public CacheLoader<Object, Object> cacheLoader() {
        return string -> {
            return string;
        };
    }

我这样使用它:cacheManager 是自动连接的:cacheManager.getCache("cacheKey").get(123)

如何将其更改为异步?

4

0 回答 0