redis支持那些语言可以操作:
找到客户端点进去:
- @Test
- public void test01(){
- //连接redis--->必须保证你的redis服务运行远程连接。
- //该对象中把每个redis命令封装成对应的方法了。
- Jedis jedis=new Jedis("192.168.223.155",6380);
- //对于字符串操作的命令
- String s = jedis.set("k1", "v1");
- System.out.println(s);
- String setex = jedis.setex("k2", 30l, "v2");
- System.out.println(setex);
- Long aLong = jedis.setnx("k3", "v11");
- System.out.println(aLong);
-
- //对于hash操作
- jedis.hset("k4","name","刘德华");
- jedis.hset("k4","age","15");
-
- Map
map=new HashMap(); - map.put("name","张需要");
- map.put("age","28");
- jedis.hset("k5",map);
-
-
- jedis.close();
-
- }
- @Test
- public void test03(){
- Set
nodes=new HashSet<>(); - nodes.add(new HostAndPort("192.168.223.155",6001));
- nodes.add(new HostAndPort("192.168.223.155",6002));
- nodes.add(new HostAndPort("192.168.223.155",6003));
- nodes.add(new HostAndPort("192.168.223.155",6004));
- nodes.add(new HostAndPort("192.168.223.155",6005));
- nodes.add(new HostAndPort("192.168.223.155",6006));
- JedisCluster jedisCluster=new JedisCluster(nodes);
-
- jedisCluster.set("k6","刘德华和闫克起");
-
- jedisCluster.close();
-
- }