本文整理汇总了Java中org.redisson.Config类的典型用法代码示例。如果您正苦于以下问题:Java Config类的具体用法?Java Config怎么用?Java Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Config类属于org.redisson包,在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import org.redisson.Config; //导入依赖的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
示例2: SingleConnectionManager
import org.redisson.Config; //导入依赖的package包/类
public SingleConnectionManager(SingleServerConfig cfg, Config config) {
MasterSlaveServersConfig newconfig = new MasterSlaveServersConfig();
String addr = cfg.getAddress().getHost() + ":" + cfg.getAddress().getPort();
newconfig.setRetryAttempts(cfg.getRetryAttempts());
newconfig.setRetryInterval(cfg.getRetryInterval());
newconfig.setTimeout(cfg.getTimeout());
newconfig.setPingTimeout(cfg.getPingTimeout());
newconfig.setPassword(cfg.getPassword());
newconfig.setDatabase(cfg.getDatabase());
newconfig.setClientName(cfg.getClientName());
newconfig.setMasterAddress(addr);
newconfig.setMasterConnectionPoolSize(cfg.getConnectionPoolSize());
newconfig.setSubscriptionsPerConnection(cfg.getSubscriptionsPerConnection());
newconfig.setSlaveSubscriptionConnectionPoolSize(cfg.getSubscriptionConnectionPoolSize());
init(newconfig, config);
}
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:18,代码来源:SingleConnectionManager.java
示例3: main
import org.redisson.Config; //导入依赖的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
示例4: getRedissonStoreFactory
import org.redisson.Config; //导入依赖的package包/类
public RedissonStoreFactory getRedissonStoreFactory() {
// TODO 这里现在使用的Redis单点
String[] addresses = redisAddresses.split(",");
Config config = new Config();
SingleServerConfig singleServerConfig = config.useSingleServer();
singleServerConfig.setAddress(addresses[0]);
singleServerConfig.setDatabase(redisDB);
singleServerConfig.setTimeout(3000);
singleServerConfig.setConnectionPoolSize(50);
RedissonClient redissonClient = Redisson.create(config);
return new RedissonStoreFactory(redissonClient);
}
开发者ID:bridgeli,项目名称:netty-socketio-demo,代码行数:13,代码来源:PushServer.java
示例5: init
import org.redisson.Config; //导入依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
if (!config.getString("redis.type").equals("master_slave")) {
throw new IllegalStateException("RedisSyncSingleStorage class can only be used with master slave 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.lettuceMasterSlave = RedisClient.create(lettuceURI);
this.lettuceMasterSlaveConn = MasterSlave.connect(this.lettuceMasterSlave, new Utf8StringCodec(), lettuceURI);
this.lettuceMasterSlaveConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));
// redisson
String masterNode = address.get(0);
String[] slaveNodes = address.subList(1, address.size()).toArray(new String[address.size() - 1]);
Config redissonConfig = new Config();
redissonConfig.useMasterSlaveServers()
.setMasterAddress(masterNode)
.setLoadBalancer(new RoundRobinLoadBalancer())
.addSlaveAddress(slaveNodes)
.setReadMode(ReadMode.MASTER)
.setDatabase(databaseNumber)
.setPassword(StringUtils.isNotEmpty(password) ? password : null);
this.redisson = Redisson.create(redissonConfig);
// params
initParams(config);
}
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:33,代码来源:RedisSyncMasterSlaveStorage.java
示例6: init
import org.redisson.Config; //导入依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
if (!config.getString("redis.type").equals("cluster")) {
throw new IllegalStateException("RedisSyncSingleStorage class can only be used with cluster 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.lettuceCluster = RedisClusterClient.create(lettuceURI);
this.lettuceCluster.setOptions(new ClusterClientOptions.Builder()
.refreshClusterView(true)
.refreshPeriod(1, TimeUnit.MINUTES)
.build());
this.lettuceClusterConn = this.lettuceCluster.connect();
this.lettuceClusterConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));
// redisson
Config redissonConfig = new Config();
redissonConfig.useClusterServers()
.setScanInterval(60000)
.addNodeAddress(address.toArray(new String[address.size()]))
.setReadMode(ReadMode.MASTER)
.setPassword(StringUtils.isNotEmpty(password) ? password : null);
this.redisson = Redisson.create(redissonConfig);
// params
initParams(config);
}
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:33,代码来源:RedisSyncClusterStorage.java
示例7: init
import org.redisson.Config; //导入依赖的package包/类
@Override
public void init(AbstractConfiguration config) {
if (!config.getString("redis.type").equals("sentinel")) {
throw new IllegalStateException("RedisSyncSingleStorage class can only be used with sentinel redis setup, but redis.type value is " + config.getString("redis.type"));
}
List<String> address = parseRedisAddress(config.getString("redis.address"), 26379);
int databaseNumber = config.getInt("redis.database", 0);
String password = StringUtils.isNotEmpty(config.getString("redis.password")) ? config.getString("redis.password") + "@" : "";
String masterId = config.getString("redis.master");
// lettuce
RedisURI lettuceURI = RedisURI.create("redis-sentinel://" + password + String.join(",", address) + "/" + databaseNumber + "#" + masterId);
this.lettuceSentinel = RedisClient.create(lettuceURI);
this.lettuceSentinelConn = MasterSlave.connect(this.lettuceSentinel, new Utf8StringCodec(), lettuceURI);
this.lettuceSentinelConn.setReadFrom(ReadFrom.valueOf(config.getString("redis.read")));
// redisson
Config redissonConfig = new Config();
redissonConfig.useSentinelServers()
.setMasterName(masterId)
.addSentinelAddress(address.toArray(new String[address.size()]))
.setReadMode(ReadMode.MASTER)
.setDatabase(databaseNumber)
.setPassword(StringUtils.isNotEmpty(password) ? password : null);
this.redisson = Redisson.create(redissonConfig);
// params
initParams(config);
}
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:31,代码来源:RedisSyncSentinelStorage.java
示例8: initRedisson
import org.redisson.Config; //导入依赖的package包/类
@BeforeClass
public static void initRedisson() {
Config config = new Config();
config.useSingleServer()
.setAddress(TestConfig.HOST_NAME + ":" + TestConfig.PORT)
.setConnectionPoolSize(100);
redisson = Redisson.create(config);
}
开发者ID:walle-liao,项目名称:jaf-examples,代码行数:9,代码来源:RedissonTestBase.java
示例9: ClusterConnectionManager
import org.redisson.Config; //导入依赖的package包/类
public ClusterConnectionManager(ClusterServersConfig cfg, Config config) {
init(config);
this.config = create(cfg);
init(this.config);
for (URI addr : cfg.getNodeAddresses()) {
RedisClient client = createClient(addr.getHost(), addr.getPort(), cfg.getTimeout());
try {
RedisConnection connection = client.connect();
String nodesValue = connection.sync(RedisCommands.CLUSTER_NODES);
Map<Integer, ClusterPartition> partitions = parsePartitions(nodesValue);
for (ClusterPartition partition : partitions.values()) {
addMasterEntry(partition, cfg);
}
break;
} catch (RedisConnectionException e) {
log.warn(e.getMessage(), e);
} finally {
client.shutdownAsync();
}
}
monitorClusterChange(cfg);
}
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:29,代码来源:ClusterConnectionManager.java
示例10: init
import org.redisson.Config; //导入依赖的package包/类
protected void init(Config cfg) {
if (cfg.isUseLinuxNativeEpoll()) {
this.group = new EpollEventLoopGroup(cfg.getThreads());
this.socketChannelClass = EpollSocketChannel.class;
} else {
this.group = new NioEventLoopGroup(cfg.getThreads());
this.socketChannelClass = NioSocketChannel.class;
}
this.codec = cfg.getCodec();
}
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:11,代码来源:MasterSlaveConnectionManager.java
示例11: before
import org.redisson.Config; //导入依赖的package包/类
@Before
public void before() {
config = new Config();
// config.setUseLinuxNativeEpoll(true);
// config.useSingleServer().setAddress("127.0.0.1:6379");
config.useClusterServers()
.addNodeAddress("127.0.0.1:7001", "127.0.0.1:7002", "127.0.0.1:7003");
}
开发者ID:Jdoing,项目名称:example,代码行数:9,代码来源:BaseTest.java
示例12: main
import org.redisson.Config; //导入依赖的package包/类
public static void main(String[] args) {
Config config = new Config();
config.useClusterServers().setScanInterval(2000) // sets cluster state scan interval
.addNodeAddress("127.0.0.1:7000", "127.0.0.1:7001", "127.0.0.1:7002")
.addNodeAddress("127.0.0.1:7003", "127.0.0.1:7004", "127.0.0.1:7005");
Redisson redisson = Redisson.create(config);
RBucket<Integer> bucket = redisson.getBucket("test");
bucket.set(6379);
System.out.println(bucket.get());
concurrentLock(redisson);
}
开发者ID:colddew,项目名称:mix-web,代码行数:16,代码来源:RedissonClient.java
示例13: MasterSlaveConnectionManager
import org.redisson.Config; //导入依赖的package包/类
public MasterSlaveConnectionManager(MasterSlaveServersConfig cfg, Config config) {
init(cfg, config);
}
开发者ID:rollenholt-SourceReading,项目名称:redisson,代码行数:4,代码来源:MasterSlaveConnectionManager.java
示例14: createRedissonClient
import org.redisson.Config; //导入依赖的package包/类
protected Redisson createRedissonClient()
{
Config config = new Config();
config.useSingleServer().setAddress(this.redisSingleServerAddress);
return Redisson.create(config);
}
开发者ID:Smartling,项目名称:hubspot-rest-sdk-java,代码行数:7,代码来源:RedisCachedTokenProvider.java
示例15: test
import org.redisson.Config; //导入依赖的package包/类
@Test
public void test() throws Exception {
// jedis
JedisPool jedisPool = new JedisPool("127.0.0.1", 6379);
// redisson
Config config = new Config().setCodec(new KryoCodec());
config.useSingleServer().setAddress("127.0.0.1:6379");
Redisson redisson = Redisson.create(config);
// flush db
jedisPool.getResource().flushDB();
StoredSession storedSession1 = new StoredSession();
String uuid1 = UUID.randomUUID().toString();
storedSession1.setPrincipal(uuid1);
storedSession1.setId(uuid1);
storedSession1.setMaxAge(20);
storedSession1.setCreationTime(System.currentTimeMillis());
storedSession1.setLastAccessTime(storedSession1.getCreationTime());
StoredSession storedSession2 = new StoredSession();
String uuid2 = UUID.randomUUID().toString();
storedSession2.setPrincipal(uuid2);
storedSession2.setId(uuid2);
storedSession2.setMaxAge(20);
storedSession2.setCreationTime(System.currentTimeMillis());
storedSession2.setLastAccessTime(storedSession1.getCreationTime());
storedSession2.setAttribute("key1", "val");
storedSession2.setAttribute("key2", 3);
redisson.getBucket(uuid1).set(storedSession1, storedSession1.getTTL(), TimeUnit.SECONDS);
RBucket<StoredSession> bucket = redisson.<StoredSession>getBucket(uuid1);
storedSession1 = bucket.get();
assertNotNull(storedSession1);
SessionRepository sessionRepository = new JedisKryoSessionRepository(jedisPool, new BoundedObjectPool<>(5, 60, 30000, Kryo::new));
//SessionRepository sessionRepository = new RedissonSessionRepository(redisson);
sessionRepository.saveSession("", storedSession1);
sessionRepository.saveSession("", storedSession2);
assertEquals(storedSession1.getPrincipal(), sessionRepository.findSession("", storedSession1.getId()).getPrincipal());
Collection<String> sessions = sessionRepository.findSessions("")
.map(StoredSession::getPrincipal)
.collect(ConcurrentLinkedQueue::new, ConcurrentLinkedQueue::add, ConcurrentLinkedQueue::addAll);
assertEquals(2, sessions.size());
assertTrue(sessions.contains(uuid1));
assertTrue(sessions.contains(uuid2));
JsonMapper mapper = new GroovyJsonMapper();
JedisJsonSessionRepository jedisJsonSessionRepository = new JedisJsonSessionRepository(jedisPool, mapper);
jedisJsonSessionRepository.saveSession("json", storedSession2);
StoredSession storedSession3 = jedisJsonSessionRepository.findSession("json", uuid2);
//assertEquals(mapper.toJson(storedSession2), mapper.toJson(storedSession3));
assertEquals(storedSession2.toString(), storedSession3.toString());
for (Method method : StoredSession.class.getDeclaredMethods()) {
if (method.getParameterCount() == 0 && method.getReturnType() != Void.class) {
System.out.println(method.getName());
assertEquals(method.invoke(storedSession2), method.invoke(storedSession3));
}
}
}
开发者ID:guestful,项目名称:module.jaxrs-filter-security,代码行数:64,代码来源:RedissonSessionRepositoryTest.java
注:本文中的org.redisson.Config类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论