我们的AWS lambda使用一个连接连接到redis 6和6.1.5。它在一个事务中写入一组字符串。
RedisCommands<String, String> redisCommands = redisConnection.sync();
// cache the whole set in one transaction
redisCommands.multi();
val.stream().forEach(
(String s ) -> { redisCommands.sadd(key, s); }
);
redisCommands.expire(key, ttl);
TransactionResult transactionResult = redisCommands.exec();
if( transactionResult.wasDiscarded() ) {
logger.error(" Redis not able to write set of strings for key = " + key);
}
同时,另一个使用相同连接的线程为另一个键写入一个简单的字符串值,
RedisCommands<String, String> redisCommands = redisConnection.sync();
redisCommands.set(key2, val);
redisCommands.expire(key2, ttl);
在对这段代码进行负载测试时,我得到了一些
JAVAUnsupportedOperationException:io。莴苣果心输出StatusOutput不支持设置(长)
到处都是。我只写片子时没有这样的问题。四处搜索并没有给我多少该做什么的信息。当我们需要用主线程编写一组字符串,而用另一个线程编写一个简单的字符串时,我们的用例中建议使用redis/莴苣的用法是什么?
谢谢你的帮助/线索/建议