package com.company;
import com.udpwork.ssdb.*;
/*
sdk介绍以及下载
介绍:http://ssdb.io/zh_cn/
下载:https://github.com/ssdb/javassdb
javassdb 里面的 demo 我试过了 是可以的
引用:https://www.cnblogs.com/alichengxuyuan/p/12577051.html 博客 里面的信息很有价值
*/
public class SsdbCl {
public static void main(String[] args) throws Exception {
SSDB ssdb = null;
Response resp;
byte[] b;
ssdb = new SSDB("localhost ", 6399);
System.out.println("---- connected -----");
// 注意: 如果某个命令没有对应的函数, 你就使用 request() 方法来执行
resp = ssdb.request("qpush", "q", "a");
for(int i=1; i
String s = new String(resp.raw.get(i));
System.out.println(s);
}
/* kv */
System.out.println("---- kv -----");
ssdb.set("a", "123");
b = ssdb.get("a");
System.out.println(new String(b));
ssdb.del("a");
b = ssdb.get("a");
System.out.println(b);
ssdb.incr("a", 10);
resp = ssdb.scan("", "", 10);
resp.print();
resp = ssdb.rscan("", "", 10);
resp.print();
System.out.println("");
/* hashmap */
System.out.println("---- hashmap -----");
ssdb.hset("n", "a", "123");
b = ssdb.hget("n", "a");
System.out.println(new String(b));
ssdb.hdel("n", "a");
b = ssdb.hget("n", "a");
System.out.println(b);
ssdb.hincr("n", "a", 10);
resp = ssdb.hscan("n", "", "", 10);
resp.print();
System.out.println("");
/* zset */
System.out.println("---- zset -----");
Long d;
ssdb.zset("n", "a", 123);
d = ssdb.zget("n", "a");
System.out.println(d);
ssdb.zdel("n", "a");
d = ssdb.zget("n", "a");
System.out.println(d);
ssdb.zincr("n", "a", 10);
resp = ssdb.zscan("n", "", null, null, 10);
resp.print();
System.out.println("");
/* multi */
ssdb.multi_set("a", "1", "b", "2");
resp = ssdb.multi_get("a", "b");
resp.print();
System.out.println("");
//
ssdb.close();
}
}