Java Jedis: 如何删除指定 Key 的 Value
使用 Java Jedis 库删除 Redis 中指定 Key 的 Value,可以通过调用 Jedis 的 del() 方法来实现。具体的步骤如下:
- 创建 Jedis 实例,并连接到 Redis 服务:
Jedis jedis = new Jedis('localhost', 6379);
- 使用 del() 方法删除指定的 Key 的 Value:
jedis.del('key');
- 关闭 Jedis 连接:
jedis.close();
完整的示例代码如下:
import redis.clients.jedis.Jedis;
public class JedisExample {
public static void main(String[] args) {
// 创建 Jedis 实例,并连接到 Redis 服务
Jedis jedis = new Jedis('localhost', 6379);
// 删除指定的 Key 的 Value
jedis.del('key');
// 关闭 Jedis 连接
jedis.close();
}
}
原文地址: https://www.cveoy.top/t/topic/qFhF 著作权归作者所有。请勿转载和采集!