我想向redis添加数据:
object Obj1 {
val redis = new RedisClient
def insert(): Unit = {
val data = List(
(111, 222, 333),
(444, 555, 666)
)
for ((x, i) <- data.zipWithIndex) {
redis lpush (f"key1$i", x._1)
redis lpush (f"key2$i", x._2)
}
}
}
它在运行时抱怨:
[error] (run-main) java.lang.Exception: ERR Operation against a key holding the wrong kind of value
java.lang.Exception: ERR Operation against a key holding the wrong kind of value
$i
由于某种原因,它会这样做。甚至“key123”也会导致错误。