当前位置: 首页>>代码示例>>Java>>正文


Java Redisson.create方法代码示例

本文整理汇总了Java中org.redisson.Redisson.create方法的典型用法代码示例。如果您正苦于以下问题:Java Redisson.create方法的具体用法?Java Redisson.create怎么用?Java Redisson.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.redisson.Redisson的用法示例。


在下文中一共展示了Redisson.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mapsLocalCache2

import org.redisson.Redisson; //导入方法依赖的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.Redisson; //导入方法依赖的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.Redisson; //导入方法依赖的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.Redisson; //导入方法依赖的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: init

import org.redisson.Redisson; //导入方法依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
    if (!config.getString("redis.type").equals("single")) {
        throw new IllegalStateException("RedisSyncSingleStorage class can only be used with single redis setup, but redis.type value is " + config.getString("redis.type"));
    }

    List<String> address = parseRedisAddress(config.getString("redis.address"), 6379);
    int databaseNumber = config.getInt("redis.database", 0);
    String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";

    // lettuce
    RedisURI lettuceURI = RedisURI.create("redis://" + password + address.get(0) + "/" + databaseNumber);
    this.lettuce = RedisClient.create(lettuceURI);
    this.lettuceConn = this.lettuce.connect();

    // redisson
    Config redissonConfig = new Config();
    redissonConfig.useSingleServer()
            .setAddress(address.get(0))
            .setDatabase(databaseNumber)
            .setPassword(StringUtils.isNotEmpty(password) ? password : null);
    this.redisson = Redisson.create(redissonConfig);

    // params
    initParams(config);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:27,代码来源:RedisSyncSingleStorage.java

示例6: main

import org.redisson.Redisson; //导入方法依赖的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

示例7: main

import org.redisson.Redisson; //导入方法依赖的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.Redisson; //导入方法依赖的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

示例9: main

import org.redisson.Redisson; //导入方法依赖的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

示例10: main

import org.redisson.Redisson; //导入方法依赖的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

示例11: main

import org.redisson.Redisson; //导入方法依赖的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

示例12: main

import org.redisson.Redisson; //导入方法依赖的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);
	// connects to 127.0.0.1:6379 by default
	final RedissonClient server = Redisson.create(config);
	final RedissonClient client = Redisson.create(config);
	try {
		server.getRemoteService().register(RemoteInterface.class, new RemoteImpl());

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

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

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

}
 
开发者ID:KleeGroup,项目名称:vertigo-labs,代码行数:24,代码来源:RemoteServiceExamples.java

示例13: main

import org.redisson.Redisson; //导入方法依赖的package包/类
public static void main(final String[] args) throws InterruptedException, ExecutionException {
	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 RedissonNodeConfig nodeConfig = new RedissonNodeConfig(config);
	nodeConfig.setExecutorServiceWorkers(Collections.singletonMap("myExecutor", 1));
	final RedissonNode node = RedissonNode.create(nodeConfig);
	node.start();

	final RedissonClient client = Redisson.create(config);
	final RExecutorService e = client.getExecutorService("myExecutor");
	System.out.println("executorService.isShutdown :" + e.isShutdown());
	System.out.println("executorService.isTerminated :" + e.isTerminated());
	//e.execute(new RunnableTask());
	final Future<String> result = e.submit(new CallableTask());
	System.out.println("result =" + result.get());
	e.shutdown();

	node.shutdown();
}
 
开发者ID:KleeGroup,项目名称:vertigo-labs,代码行数:24,代码来源:ExecutorServiceExamples.java

示例14: main

import org.redisson.Redisson; //导入方法依赖的package包/类
public static void main(String[] args) {
    Config config = new Config();
    config.useSingleServer()
            .setAddress("168.168.3.59:6379");

    Redisson redisson = Redisson.create(config);
    
    long s = System.nanoTime();
    RSet<String> set = redisson.getSet("anySet");
    set.add("a");
    
    long e = System.nanoTime();
    System.out.println("need time" + (e - s)/1000000);
    
    long s1 = System.nanoTime();
    RSortedSet rss = redisson.getSortedSet("rs");
    rss.add("ddddddddddd");
    long e1 = System.nanoTime();
    
    System.out.println("need time" + (e1 - s1)/1000000 + " ms");
    
}
 
开发者ID:laizhihuan,项目名称:java-test-demo,代码行数:23,代码来源:RedissonClient.java

示例15: connectRedis

import org.redisson.Redisson; //导入方法依赖的package包/类
/**
 * Connects to a redis server with given config.<br>
 * It is recommended to set the address and authentification to the config.<br>
 * Example: {@link org.redisson.config.SingleServerConfig#setAddress(URI)}
 *
 * @param config The redisson config
 */
public void connectRedis(Config config) {
    if(this.client != null) return;
    this.config = config;

    if(config != null) {
        this.client = Redisson.create(config);
    }
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:16,代码来源:RedisConnection.java


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