Java Redis 客戶端:labs-redis
labs-redis是一個使用JBoss Netty (N)IO開發的Java Redis 客戶端。
labs-redis公開兩個級別的API。最低水平實現了Redis的請求/響應協議。
// creates a protocol client connecting to 127.0.0.1
RedisProtocolClient client = new RedisProtocolClient();
// sends PING and prints response
System.out.println("ping -> " + client.send("PING").asString());</pre></code>
暴露的Redis命令API
RedisClient client = new RedisClient("127.0.0.1", 6379);
// set a value and wait for server response
// set() returns a ResponseFuture
client.set("mykey", "myvalue").block();
// the future allows client to control timeouts
Object value = client.
get("mykey").
withTimeout(1, TimeUnit.SECONDS);
System.out.println("mykey = " + value);
// and response type demarshalling and conversions
String value2 = client.get("mykey").asString();
System.out.println("mykey = " + value2);</pre></code>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!