✅Test: Redis 连接测试
This commit is contained in:
@@ -4,9 +4,9 @@ import redis.clients.jedis.Jedis;
|
||||
|
||||
/**
|
||||
* Redis连接测试类
|
||||
* TODO: 实现Redis连接测试
|
||||
* TODO: 验证Redis服务器是否正常运行
|
||||
* TODO: 测试基本的Redis操作
|
||||
* DONE: 实现Redis连接测试
|
||||
* DONE: 验证Redis服务器是否正常运行
|
||||
* DONE: 测试基本的Redis操作
|
||||
*/
|
||||
public class RedisConnectionTest {
|
||||
|
||||
@@ -30,8 +30,9 @@ public class RedisConnectionTest {
|
||||
System.out.println("测试Redis连接...");
|
||||
try {
|
||||
// 创建Jedis连接
|
||||
Jedis jedis = new Jedis("localhost", 6379);
|
||||
|
||||
Jedis jedis = new Jedis("47.121.181.112", 6379, 2000);
|
||||
|
||||
jedis.auth("dn293830");
|
||||
// 测试连接
|
||||
String pingResult = jedis.ping();
|
||||
System.out.println("Redis连接测试结果: " + pingResult);
|
||||
@@ -56,7 +57,9 @@ public class RedisConnectionTest {
|
||||
private static void testBasicOperations() {
|
||||
System.out.println("测试基本操作...");
|
||||
try {
|
||||
Jedis jedis = new Jedis("localhost", 6379);
|
||||
Jedis jedis = new Jedis("47.121.181.112", 6379, 2000);
|
||||
|
||||
jedis.auth("dn293830");
|
||||
|
||||
// 测试字符串操作
|
||||
jedis.set("test_key", "test_value");
|
||||
|
||||
Reference in New Issue
Block a user