本文整理汇总了Java中com.basho.riak.client.bucket.Bucket类的典型用法代码示例。如果您正苦于以下问题:Java Bucket类的具体用法?Java Bucket怎么用?Java Bucket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Bucket类属于com.basho.riak.client.bucket包,在下文中一共展示了Bucket类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import com.basho.riak.client.bucket.Bucket; //导入依赖的package包/类
public static void delete(String bucket, String key) {
Bucket b;
try {
b = getBucket(bucket);
if (b != null)
b.delete(key).rw(3).execute();
} catch (RiakException e) {
e.printStackTrace();
}
}
示例2: getValue
import com.basho.riak.client.bucket.Bucket; //导入依赖的package包/类
static private byte[] getValue(String bucket, String key) {
try {
Bucket b = riak.fetchBucket(bucket).execute();
if (b != null) {
IRiakObject obj = b.fetch(key).execute();
if (obj != null)
return obj.getValue();
}
} catch (RiakRetryFailedException e) {
e.printStackTrace();
}
return null;
}
示例3: getBucket
import com.basho.riak.client.bucket.Bucket; //导入依赖的package包/类
static private Bucket getBucket(String bucket) throws RiakException {
Bucket res = riak.fetchBucket(bucket).execute();
if (res == null) {
return riak.createBucket("bucket").execute();
} else
return res;
}
示例4: executeReadQuery
import com.basho.riak.client.bucket.Bucket; //导入依赖的package包/类
private StringToStringMap executeReadQuery(IRiakClient client, String bucketName, String key) {
try {
Bucket bucket = client.fetchBucket(bucketName).execute();
FetchObject<StringToStringMap> fetchObj = bucket.fetch(key, StringToStringMap.class);
return fetchObj.r(DEFAULT_READ_QUORUM).execute();
} catch (Exception exc) {
System.out.println("EXCEPTION: " + exc);
return null;
}
}
示例5: executeWriteQuery
import com.basho.riak.client.bucket.Bucket; //导入依赖的package包/类
private int executeWriteQuery(IRiakClient client, String bucketName, String key, StringToStringMap dataToWrite){
try {
Bucket bucket = client.fetchBucket(bucketName).execute();
StoreObject<StringToStringMap> storeObject = bucket.store(key, dataToWrite);
storeObject.w(DEFAULT_WRITE_QUORUM).execute();
} catch (Exception e) {
return ERROR;
}
return OK;
}