xmemcached發布1.3.3版本——支持touch和GAT
開源memcached的java客戶端xmemcached發布1.3.3,主要改進如下:1、memcached 1.6添加了不少新特性,具體可以參考《what's new in memcached》(1) (2)這兩個帖子。xmemcached將及時跟進這些新特性。1.3.3這個版本實現了二進製協議中新的兩個命令touch和GAT(get and touch)。這兩個功能可以說是千唿萬喚始出來,終於可以不用get-set來重新設置數據的超時時間,利用touch或者GAT可以簡單地更新數據的超時時間。1.3.3新增加四個方法:
public boolean touch(final String key, int exp, long opTimeout)
throws TimeoutException, InterruptedException, MemcachedException;
public boolean touch(final String key, int exp) throws TimeoutException,
InterruptedException, MemcachedException;
public <T> T getAndTouch(final String key, int newExp, long opTimeout)
throws TimeoutException, InterruptedException, MemcachedException;
public <T> T getAndTouch(final String key, int newExp)
throws TimeoutException, InterruptedException, MemcachedException;
throws TimeoutException, InterruptedException, MemcachedException;
public boolean touch(final String key, int exp) throws TimeoutException,
InterruptedException, MemcachedException;
public <T> T getAndTouch(final String key, int newExp, long opTimeout)
throws TimeoutException, InterruptedException, MemcachedException;
public <T> T getAndTouch(final String key, int newExp)
throws TimeoutException, InterruptedException, MemcachedException;
其中touch用於設置數據新的超時時間,getAndTouch則是在獲取數據的同時更新超時時間。例如用memcached存儲session,可以在每次get的時候更新下數據的超時時間來保活。請注意,這四個方法僅在使用memcached 1.6並且使用二進製協議的時候有效。
2、setLoggingLevelVerbosity方法可以作用於二進製協議。
3、重構錯誤處理模塊,使得異常信息更友好。
4、將KeyIterator和getKeyIterator聲明為deprecated,因為memached 1.6將移除stats cachedump協議,並且stats cachedump返回數據有大小限製,遍曆功能不具實用性。
5、修複Bug,包括issue 126 ,issue 127,issue 128,issue 129。
下載地址:https://code.google.com/p/xmemcached/downloads/list
源碼: https://github.com/killme2008/xmemcached
maven引用:
<dependency>
<groupId>com.googlecode.xmemcached</groupId>
<artifactId>xmemcached</artifactId>
<version>1.3.3</version>
</dependency>
<groupId>com.googlecode.xmemcached</groupId>
<artifactId>xmemcached</artifactId>
<version>1.3.3</version>
</dependency>
文章轉自莊周夢蝶 ,原文發布時間
最後更新:2017-05-18 18:05:06