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


Java Config类代码示例

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


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

示例1: mapsLocalCache2

import org.redisson.config.Config; //导入依赖的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.config.Config; //导入依赖的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.config.Config; //导入依赖的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.config.Config; //导入依赖的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.config.Config; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
        Config config = new Config();
//        config.setUseLinuxNativeEpoll(true);
        config.useSingleServer().setAddress("127.0.0.1:6379");
        Redisson redisson = (Redisson) Redisson.create(config);

        CounterManager counterManager = new RedissonCounterManager(redisson);
        //重置
        counterManager.getCounter("test").set(0);

        for (int i = 0; i < 100; i++) {
            new Thread(() -> counterManager.getCounter("test").increment()).start();
        }

        Thread.sleep(500);
        Assert.assertEquals(counterManager.getCounter("test").get(), 100);
        redisson.shutdown();

    }
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:20,代码来源:RedissonCounterTest.java

示例6: main

import org.redisson.config.Config; //导入依赖的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.config.Config; //导入依赖的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

示例8: main

import org.redisson.config.Config; //导入依赖的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

示例9: main

import org.redisson.config.Config; //导入依赖的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

示例10: main

import org.redisson.config.Config; //导入依赖的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

示例11: main

import org.redisson.config.Config; //导入依赖的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

示例12: RedisModule

import org.redisson.config.Config; //导入依赖的package包/类
public RedisModule(File configFile, Logger logger) {
    this.logger = logger;
    this.configFile = configFile;
    this.redisConnection = new RedisConnection();

    try {
        this.config = configFile.getName().endsWith(".json") ? Config.fromJSON(configFile) : Config.fromYAML(configFile);
    }
    catch(IOException e) {
        logger.severe("Error while loading Redis config! " + e);
        super.finished(false);
    }
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:14,代码来源:RedisModule.java

示例13: connectRedis

import org.redisson.config.Config; //导入依赖的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

示例14: mapsLocalCache

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

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

    Waiter waiter = new Waiter();
    map.put("key", 20);
    new Thread(() -> {
        mapsLocalCache2(waiter);
        waiter.resume();
    }).start();


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

    System.out.println("SET");
    map.put("key", 25);
    try {
        waiter.await();
    }
    catch(Throwable throwable) {
        throwable.printStackTrace();
    }
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:34,代码来源:RedisTest.java

示例15: mapsItemChange

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

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

    FinalValue value = new FinalValue(15);
    map.put("test", value);

    Waiter waiter = new Waiter();

    System.out.println("Value: " + value.get());
    new Thread(() -> {
        mapsItemChange2(waiter);
        waiter.resume();
    }).start();

    try {
        Thread.sleep(1000);
    }
    catch(InterruptedException e) {
        e.printStackTrace();
    }
    value.set(18);
    map.put("test", value);
    System.out.println("VALUE SET.");

    try {
        waiter.await();
    }
    catch(Throwable throwable) {
        throwable.printStackTrace();
    }
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:38,代码来源:RedisTest.java


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