运行代码片段:
/**
* Using the synchronous interface
*/
public static void usingSyncClient () {
ConnectionSpec spec = DefaultConnectionSpec.newSpec("192.168.68.110",6666,0,null)
.setCredentials("mypass".getBytes())
.setDatabase(10);
JRedis jredis = new JRedisClient(spec);
System.out.println ("\nusing the SyncClient: \n\n");
try {
Strings<String> kvSet = BulkSetMapping.newStringKVSet();
kvSet
.add("foo", "woof")
.add("bar", "meow")
.add("paz", "thesalt");
// mappings.add("ewe", "dwe");
jredis.mset(kvSet);
} catch (RedisException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//useMSet (jredis);
// useMSetNX (jredis);
jredis.quit();
}
** 异常信息:
01447661803808 Mon Nov 16 16:16:43 CST 2015 JRedis[tid:10] <信息>: WARNING: heartbeat is disabled.
01447661803831 Mon Nov 16 16:16:43 CST 2015 JRedis[tid:10] <严重>: Error response for MSET => ERR Protocol error: expected '$', got '*'
Exception on [MSET] => ERR Protocol error: expected '$', got '*'
at org.jredis.ri.alphazero.connection.SyncConnection.serviceRequest(SyncConnection.java:156)
at org.jredis.ri.alphazero.JRedisClient.serviceRequest(JRedisClient.java:151)
at org.jredis.ri.alphazero.JRedisSupport.mset(JRedisSupport.java:1140)
at org.jredis.ri.alphazero.JRedisSupport.mset(JRedisSupport.java:1156)
at org.jredis.examples.commands.UsingBulkCommands.usingSyncClient(UsingBulkCommands.java:119)
at org.jredis.examples.commands.UsingBulkCommands.main(UsingBulkCommands.java:48)