本文整理汇总了Java中org.redisson.api.RedissonClient.getBucket方法的典型用法代码示例。如果您正苦于以下问题:Java RedissonClient.getBucket方法的具体用法?Java RedissonClient.getBucket怎么用?Java RedissonClient.getBucket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.redisson.api.RedissonClient
的用法示例。
在下文中一共展示了RedissonClient.getBucket方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.redisson.api.RedissonClient; //导入方法依赖的package包/类
public static void main(String[] args) {
RedissonClient redisson = Redisson.create();
RBucket<String> bucket = redisson.getBucket("test");
bucket.set("123");
boolean isUpdated = bucket.compareAndSet("123", "4934");
String prevObject = bucket.getAndSet("321");
boolean isSet = bucket.trySet("901");
long objectSize = bucket.size();
// set with expiration
bucket.set("value", 10, TimeUnit.SECONDS);
boolean isNewSet = bucket.trySet("nextValue", 10, TimeUnit.SECONDS);
redisson.shutdown();
}
示例2: main
import org.redisson.api.RedissonClient; //导入方法依赖的package包/类
public static void main(String[] args) {
// connects to 127.0.0.1:6379 by default
RedissonClient redisson = Redisson.create();
RBucket<String> bucket = redisson.getBucket("test");
bucket.set("123");
boolean isUpdated = bucket.compareAndSet("123", "4934");
String prevObject = bucket.getAndSet("321");
boolean isSet = bucket.trySet("901");
long objectSize = bucket.size();
// set with expiration
bucket.set("value", 10, TimeUnit.SECONDS);
boolean isNewSet = bucket.trySet("nextValue", 10, TimeUnit.SECONDS);
redisson.shutdown();
}
示例3: main
import org.redisson.api.RedissonClient; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
Bench<RedissonClient> bench = new RedissonBench() {
@Override
public void executeOperation(String data, RedissonClient benchInstance, int threadNumber, int iteration,
MetricRegistry metrics) {
RBucket<String> bucket = benchInstance.getBucket("bucket_" + threadNumber + "_" + iteration);
Timer.Context time = metrics.timer("bucket").time();
bucket.set(data);
time.stop();
}
};
Benchmark benchmark = new Benchmark(bench);
benchmark.run(args);
}
示例4: main
import org.redisson.api.RedissonClient; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
Bench<RedissonClient> bench = new RedissonBench() {
@Override
public void executeOperation(String data, RedissonClient benchInstance, int threadNumber, int iteration,
MetricRegistry metrics) {
RBucket<Object> bucket = benchInstance.getBucket("bucket_" + threadNumber + "_" + iteration);
Timer.Context time = metrics.timer("bucket").time();
bucket.set(value);
time.stop();
}
};
Benchmark benchmark = new Benchmark(bench);
benchmark.run(args);
}