本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}