我正在尝试使用新的莴苣6.0 ClientSideCaching
功能。但我不知道如何配置它。基本上它需要 StatefulRedisConnection
我不知道怎么弄到的。这是我目前的配置。
@Configuration
public class RedisConfiguration {
private final RedisConnectionFactory connectionFactory;
private final ObjectMapper objectMapper;
private final Map<String, SiteConfiguration> localCache = new ConcurrentHashMap<>();
@Autowired
public RedisConfiguration(RedisConnectionFactory connectionFactory, ObjectMapper objectMapper) {
this.connectionFactory = connectionFactory;
this.objectMapper = objectMapper;
}
@Bean
RedisOperations<String, Record> redisOperations() {
Jackson2JsonRedisSerializer<Record> serializer = new Jackson2JsonRedisSerializer<>(Record.class);
serializer.setObjectMapper(objectMapper);
var redisTemplate = new RedisTemplate<String, Recordn>();
redisTemplate.setDefaultSerializer(serializer);
redisTemplate.setConnectionFactory(connectionFactory);
return redisTemplate;
}
@Bean
//----------------------------------------------------|
// This is not getting resolved v
CacheFrontend<String, Record> cacheFrontend(StatefulRedisConnection<String, Record> statefulRedisConnection) {
// Even this is not working connectionFactory.getConnection().getNativeConnection();
return ClientSideCaching.enable(CacheAccessor.forMap(localCache), statefulRedisConnection, TrackingArgs.Builder.enabled().noloop());
}
}
所以,想知道什么是最好的方式来配置这个。还有什么方法可以链接这个咖啡因或其他东西而不是concurrenthashmap,这样客户端就不会存储太多数据。
暂无答案!
目前还没有任何答案,快来回答吧!