jedis-2.9.0.jar
jedis-2.9.0 jar 包,不包含源码,源码下载地址:
http://download.csdn.net/download/tan3739/9993938
测试代码:
导入依赖包:
commons-lang-2.5.jar
commons-pool2-2.4.2.jar
jedis-2.9.0 jar
public static void main(String[] args) {
Jedis jedis = new Jedis("115.159.100.66", 16325);
jedis.auth("192.168akeiekekKKDJEikekEJkeu^&&%%$*($#&^$&^#$*((BNGGyjekeuh{}jejekekej:");
ping(jedis);
hashBytesSave(jedis);
hashBytesGet(jedis);
// ListCommandsTest
jedis.close();
}
static void hashBytesSave(Jedis jedis)
{
byte[] key = "Tables".getBytes();
byte[] field = "9".getBytes();
byte[] value = new byte[10240];
for (int i=0; i<10240; i++)
{
value[i] = (byte) (i % 127);
}
long saved = jedis.hset(key, field, value);
System.out.println("hashBytesSaved:"+saved);
}
static void hashBytesGet(Jedis jedis)
{
byte[] key = "Tables".getBytes();
byte[] field = "9".getBytes();
byte[] value = jedis.hget(key, field);
System.out.println("hashBytesSaved:"+Arrays.toString(value));
}
static void ping(Jedis jedis)
{
//查看服务是否运行
System.out.println("服务正在运行: "+jedis.ping());
jedis.lpush("site-list:100:title", "Try123456");
//String re = jedis.lpop("site-list:100:title");
//System.out.println("first:"+re);
System.out.println("连接成功");
}
1