• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RedissonClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.redisson.api.RedissonClient的典型用法代码示例。如果您正苦于以下问题:Java RedissonClient类的具体用法?Java RedissonClient怎么用?Java RedissonClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RedissonClient类属于org.redisson.api包,在下文中一共展示了RedissonClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: mapsLocalCache2

import org.redisson.api.RedissonClient; //导入依赖的package包/类
void mapsLocalCache2(Waiter waiter) {
    Config config = new Config();
    config.useSingleServer().setAddress("http://127.0.0.1:6379");
    RedissonClient client = Redisson.create(config);

    LocalCachedMapOptions options = LocalCachedMapOptions.defaults().maxIdle(10 * 1000).timeToLive(10 * 1000);
    RLocalCachedMap<String, Integer> map = client.getLocalCachedMap("myMap", options);

    System.out.println("KEY BEFORE: " + map.get("key"));

    try {
        Thread.sleep(2000);
    }
    catch(InterruptedException e) {
        e.printStackTrace();
    }
    System.out.println("KEY AFTER: " + map.get("key"));
    waiter.assertEquals(map.get("key"), 25);
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:20,代码来源:RedisTest.java


示例2: createInstance

import org.redisson.api.RedissonClient; //导入依赖的package包/类
@Override
    public RedissonClient createInstance(int connections, String host) {
        Config c = new Config();
//        c.setUseLinuxNativeEpoll(true);
//        c.useClusterServers()
        c.useSingleServer()
        .setTimeout(10000000)
        .setAddress(host)
        .setConnectionPoolSize(connections).setConnectionMinimumIdleSize(connections);
//        .addNodeAddress(host)
//        .setMasterConnectionPoolSize(connections).setMasterConnectionMinimumIdleSize(connections);
        c.setCodec(StringCodec.INSTANCE);

        RedissonClient r = Redisson.create(c);
        r.getKeys().flushdb();
        return r;
    }
 
开发者ID:redisson,项目名称:redisson-benchmark,代码行数:18,代码来源:RedissonBench.java


示例3: mapsItemChange2

import org.redisson.api.RedissonClient; //导入依赖的package包/类
void mapsItemChange2(Waiter waiter){
    Config config = new Config();
    config.useSingleServer().setAddress("http://127.0.0.1:6379");
    RedissonClient client = Redisson.create(config);

    LocalCachedMapOptions options = LocalCachedMapOptions.defaults().maxIdle(10 * 1000).timeToLive(10 * 1000);
    RLocalCachedMap<String, FinalValue<Integer>> map = client.getLocalCachedMap("myMap", options);
    FinalValue<Integer> value = map.get("test");
    System.out.println("Value Before: " + value.get());

    try {
        Thread.sleep(2000);
    }
    catch(InterruptedException e) {
        e.printStackTrace();
    }

    value = map.get("test");
    System.out.println("Value After: " + value.get());
    waiter.assertEquals(value.get(), 18);
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:22,代码来源:RedisTest.java


示例4: provider

import org.redisson.api.RedissonClient; //导入依赖的package包/类
public static RedissonClient provider() {
    if (client == null) {
        Config config = new Config();
        config.useSingleServer().setAddress("redis://" + REDIS_HOST + ":6379");
        client = Redisson.create(config);
    }
    return client;
}
 
开发者ID:JungleTree,项目名称:JungleTree,代码行数:9,代码来源:JungleStorageFactory.java


示例5: 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) {
            RList<String> list = benchInstance.getList("list_" + threadNumber);

            Timer.Context time = metrics.timer("list").time();
            list.add(data);
            time.stop();
        }
    };
    
    Benchmark benchmark = new Benchmark(bench);
    benchmark.run(args);
}
 
开发者ID:redisson,项目名称:redisson-benchmark,代码行数:17,代码来源:ListAddBenchmark.java


示例6: main

import org.redisson.api.RedissonClient; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
        Config config = new Config();
        config.useSingleServer().setAddress("127.0.0.1:6379");
        RedissonClient redisson = Redisson.create(config);
        Messager messager = new RedissonMessager(redisson);

        byte[] stat = new byte[1];

//        new Thread(() -> {
//            for (int i = 0; i < 1000; i++) {
//                try {
//                    Thread.sleep(1000);
//                } catch (InterruptedException e) {
//                    e.printStackTrace();
//                }
//                messager.publish(text("hello2"))
//                        .to(topic("test"))
//                        .from(user("admin"))
//                        .send();
//            }
//        }).start();
        messager.subscribe(topic("test"))
                .onMessage(System.out::println)
                .onMessage(msg -> stat[0] = 1);
        //redisson.shutdown();
    }
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:27,代码来源:RedissonMessagerTest.java


示例7: 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();
    
    RSortedSet<String> sortedSet = redisson.getSortedSet("mySortedSet");
    sortedSet.add("1");
    sortedSet.add("2");
    sortedSet.add("3");
    
    for (String string : sortedSet) {
        // iteration through bulk loaded values
    }
    
    String firstValue = sortedSet.first();
    String lastValue = sortedSet.last();
    
    boolean removedValue = sortedSet.remove("1");
    sortedSet.removeAll(Arrays.asList("1", "2", "3"));
    sortedSet.containsAll(Arrays.asList("4", "1", "0"));
    
    redisson.shutdown();
}
 
开发者ID:redisson,项目名称:redisson-examples,代码行数:23,代码来源:SortedSetExamples.java


示例8: 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();
}
 
开发者ID:redisson,项目名称:redisson-examples,代码行数:17,代码来源:BucketExamples.java


示例9: main

import org.redisson.api.RedissonClient; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
    // connects to 127.0.0.1:6379 by default
    RedissonClient redisson = Redisson.create();
    
    RLock lock = redisson.getLock("lock");
    lock.lock(2, TimeUnit.SECONDS);

    Thread t = new Thread() {
        public void run() {
            RLock lock1 = redisson.getLock("lock");
            lock1.lock();
            lock1.unlock();
        };
    };

    t.start();
    t.join();

    lock.unlock();
    
    redisson.shutdown();
}
 
开发者ID:redisson,项目名称:redisson-examples,代码行数:23,代码来源:LockExamples.java


示例10: 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();

    RHyperLogLog<String> hyperLogLog = redisson.getHyperLogLog("hyperLogLog");
    hyperLogLog.add("1");
    hyperLogLog.add("2");
    hyperLogLog.add("3");
    hyperLogLog.addAll(Arrays.asList("10", "20", "30"));
    
    RHyperLogLog<String> hyperLogLog1 = redisson.getHyperLogLog("hyperLogLog1");
    hyperLogLog1.add("4");
    hyperLogLog1.add("5");
    hyperLogLog1.add("6");
    
    RHyperLogLog<String> hyperLogLog2 = redisson.getHyperLogLog("hyperLogLog2");
    hyperLogLog1.add("4");
    hyperLogLog1.add("5");
    hyperLogLog1.add("6");
    
    hyperLogLog2.mergeWith(hyperLogLog1.getName());
    hyperLogLog2.countWith(hyperLogLog1.getName());

    redisson.shutdown();
}
 
开发者ID:redisson,项目名称:redisson-examples,代码行数:26,代码来源:HyperLogLogExamples.java


示例11: main

import org.redisson.api.RedissonClient; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
    // connects to 127.0.0.1:6379 by default
    RedissonClient redisson = Redisson.create();

    CountDownLatch latch = new CountDownLatch(1);
    
    RTopic<String> topic = redisson.getTopic("topic2");
    topic.addListener(new MessageListener<String>() {
        @Override
        public void onMessage(String channel, String msg) {
            latch.countDown();
        }
    });
    
    topic.publish("msg");
    latch.await();
    
    redisson.shutdown();
}
 
开发者ID:redisson,项目名称:redisson-examples,代码行数:20,代码来源:TopicExamples.java


示例12: 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();
}
 
开发者ID:redisson,项目名称:redisson-examples,代码行数:18,代码来源:BucketExamples.java


示例13: 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();

    RAtomicLong atomicLong = redisson.getAtomicLong("myLong");
    atomicLong.getAndDecrement();
    atomicLong.getAndIncrement();
    
    atomicLong.addAndGet(10L);
    atomicLong.compareAndSet(29, 412);
    
    atomicLong.decrementAndGet();
    atomicLong.incrementAndGet();
    
    atomicLong.getAndAdd(302);
    atomicLong.getAndDecrement();
    atomicLong.getAndIncrement();
    
    redisson.shutdown();
}
 
开发者ID:redisson,项目名称:redisson-examples,代码行数:21,代码来源:AtomicLongExamples.java


示例14: 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();

    RAtomicDouble atomicDouble = redisson.getAtomicDouble("myDouble");
    atomicDouble.getAndDecrement();
    atomicDouble.getAndIncrement();
    
    atomicDouble.addAndGet(10.323);
    atomicDouble.compareAndSet(29.4, 412.91);
    
    atomicDouble.decrementAndGet();
    atomicDouble.incrementAndGet();
    
    atomicDouble.getAndAdd(302.00);
    atomicDouble.getAndDecrement();
    atomicDouble.getAndIncrement();
    
    redisson.shutdown();
}
 
开发者ID:redisson,项目名称:redisson-examples,代码行数:21,代码来源:AtomicDoubleExamples.java


示例15: main

import org.redisson.api.RedissonClient; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    // connects to 127.0.0.1:6379 by default
    RedissonClient redisson = Redisson.create();

    RBinaryStream stream = redisson.getBinaryStream("myStream");
    
    byte[] values = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
    stream.trySet(values);
    stream.set(values);
    
    InputStream is = stream.getInputStream();
    StringBuilder sb = new StringBuilder();
    int ch;
    while((ch = is.read()) != -1) {
        sb.append((char)ch);
    }
    String str = sb.toString();
    
    OutputStream os = stream.getOutputStream();
    for (int i = 0; i < values.length; i++) {
        byte c = values[i];
        os.write(c);
    }
    
    redisson.shutdown();
}
 
开发者ID:redisson,项目名称:redisson-examples,代码行数:27,代码来源:BinaryStreamExamples.java


示例16: 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();

    RGeo<String> geo = redisson.getGeo("myGeo");
    GeoEntry entry = new GeoEntry(13.361389, 38.115556, "Palermo");
    geo.add(entry);
    geo.add(15.087269, 37.502669, "Catania");

    Double dist = geo.dist("Palermo", "Catania", GeoUnit.METERS);

    Map<String, GeoPosition> pos = geo.pos("Palermo", "Catania");

    List<String> cities = geo.radius(15, 37, 200, GeoUnit.KILOMETERS);
    List<String> allNearCities = geo.radius("Palermo", 10, GeoUnit.KILOMETERS);
    
    Map<String, Double> citiesWithDistance = geo.radiusWithDistance(15, 37, 200, GeoUnit.KILOMETERS);
    Map<String, Double> allNearCitiesDistance = geo.radiusWithDistance("Palermo", 10, GeoUnit.KILOMETERS);

    Map<String, GeoPosition> citiesWithPosition = geo.radiusWithPosition(15, 37, 200, GeoUnit.KILOMETERS);
    Map<String, GeoPosition> allNearCitiesPosition = geo.radiusWithPosition("Palermo", 10, GeoUnit.KILOMETERS);
    
    redisson.shutdown();
}
 
开发者ID:redisson,项目名称:redisson-examples,代码行数:25,代码来源:GeoExamples.java


示例17: main

import org.redisson.api.RedissonClient; //导入依赖的package包/类
public static void main(String[] args) {
    Config config = new Config();
    config.useClusterServers()
        .addNodeAddress("127.0.0.1:7001", "127.0.0.1:7002", "127.0.0.1:7003");
    
    RedissonClient redisson = Redisson.create(config);

    RedissonNodeConfig nodeConfig = new RedissonNodeConfig(config);
    nodeConfig.setExecutorServiceWorkers(Collections.singletonMap("myExecutor", 1));
    RedissonNode node = RedissonNode.create(nodeConfig);
    node.start();

    RExecutorService e = redisson.getExecutorService("myExecutor");
    e.execute(new RunnableTask());
    e.submit(new CallableTask());
    
    e.shutdown();
    node.shutdown();
}
 
开发者ID:redisson,项目名称:redisson-examples,代码行数:20,代码来源:ExecutorServiceExamples.java


示例18: main

import org.redisson.api.RedissonClient; //导入依赖的package包/类
public static void main(String[] args) {
    Config config = new Config();
    config.useClusterServers()
        .addNodeAddress("127.0.0.1:7001", "127.0.0.1:7002", "127.0.0.1:7003");
    
    RedissonClient redisson = Redisson.create(config);

    RedissonNodeConfig nodeConfig = new RedissonNodeConfig(config);
    nodeConfig.setExecutorServiceWorkers(Collections.singletonMap("myExecutor", 5));
    RedissonNode node = RedissonNode.create(nodeConfig);
    node.start();

    RScheduledExecutorService e = redisson.getExecutorService("myExecutor");
    e.schedule(new RunnableTask(), 10, TimeUnit.SECONDS);
    e.schedule(new CallableTask(), 4, TimeUnit.MINUTES);

    e.schedule(new RunnableTask(), CronSchedule.of("10 0/5 * * * ?"));
    e.schedule(new RunnableTask(), CronSchedule.dailyAtHourAndMinute(10, 5));
    e.schedule(new RunnableTask(), CronSchedule.weeklyOnDayAndHourAndMinute(12, 4, Calendar.MONDAY, Calendar.FRIDAY));
    
    e.shutdown();
    node.shutdown();
}
 
开发者ID:redisson,项目名称:redisson-examples,代码行数:24,代码来源:SchedulerServiceExamples.java


示例19: main

import org.redisson.api.RedissonClient; //导入依赖的package包/类
public static void main(String[] args) {
    // connects to 127.0.0.1:6379 by default
    RedissonClient server = Redisson.create();
    RedissonClient client = Redisson.create();
    try {
        server.getRemoteService().register(RemoteInterface.class, new RemoteImpl());

        RemoteInterface service = client.getRemoteService().get(RemoteInterface.class);

        service.myMethod(21L);

    } finally {
        client.shutdown();
        server.shutdown();
    }

}
 
开发者ID:redisson,项目名称:redisson-examples,代码行数:18,代码来源:RemoteServiceExamples.java


示例20: main

import org.redisson.api.RedissonClient; //导入依赖的package包/类
public static void main(final String[] args) {
	final Config config = new Config();
	config.useSingleServer()
			.setAddress("redis-14926.c10.us-east-1-3.ec2.cloud.redislabs.com:14926")
			.setConnectionMinimumIdleSize(1)
			.setConnectionPoolSize(2);

	final RedissonClient client = Redisson.create(config);
	try {

		final RemoteInterface service = client.getRemoteService().get(RemoteInterface.class);

		final long result = service.myMethod(21L);
		System.out.println("result = " + result);

	} finally {
		client.shutdown();
	}
}
 
开发者ID:KleeGroup,项目名称:vertigo-labs,代码行数:20,代码来源:RemoteClient.java



注:本文中的org.redisson.api.RedissonClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PNGImageReaderSpi类代码示例发布时间:2022-05-21
下一篇:
Java FileOutputCommitter类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap