Java Code Examples for org.redisson.config.SingleServerConfig#setPassword()
The following examples show how to use
org.redisson.config.SingleServerConfig#setPassword() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedissonConfig.java From dk-foundation with GNU Lesser General Public License v2.1 | 6 votes |
@Bean @ConditionalOnProperty(name="spring.redis.url") RedissonClient redissonSingle() { Config config = new Config(); SingleServerConfig serverConfig = config.useSingleServer() .setAddress(redisProperties.getUrl()) .setDatabase(redisProperties.getDatabase()); if (StringUtils.isNotBlank(redisProperties.getPassword())) { serverConfig.setPassword(redisProperties.getPassword()); } if (redisProperties.getTimeout() != null) { serverConfig.setTimeout((int) redisProperties.getTimeout().getSeconds()); } if (redisProperties.getJedis().getPool() != null) { serverConfig.setConnectionPoolSize(redisProperties.getJedis().getPool().getMaxActive()) .setConnectionMinimumIdleSize(redisProperties.getJedis().getPool().getMinIdle()); } return Redisson.create(config); }
Example 2
Source File: RedissonTest.java From java-tutorial with MIT License | 6 votes |
@Test public void test() throws InterruptedException { Config config = new Config(); SingleServerConfig singleServerConfig = config.useSingleServer(); singleServerConfig.setAddress(redssionProperties.getAddress()); singleServerConfig.setPassword(redssionProperties.getPassword()); RedissonClient redissonClient = RedisUtils.getInstance().getRedisson(config); RBucket<Object> rBucket = RedisUtils.getInstance().getRBucket(redissonClient, "key"); System.out.println(rBucket.get()); while (true) { RLock lock = redissonClient.getLock("com.lock"); lock.tryLock(0, 1, TimeUnit.SECONDS); try { System.out.println("执行"); } finally { lock.unlock(); } } }
Example 3
Source File: RedissonAutoConfiguration.java From spring-boot-seckill with GNU General Public License v2.0 | 6 votes |
/** * 单机模式自动装配 * @return */ @Bean @ConditionalOnProperty(name="redisson.address") RedissonClient redissonSingle() { Config config = new Config(); SingleServerConfig serverConfig = config.useSingleServer() .setAddress(redssionProperties.getAddress()) .setTimeout(redssionProperties.getTimeout()) .setConnectionPoolSize(redssionProperties.getConnectionPoolSize()) .setConnectionMinimumIdleSize(redssionProperties.getConnectionMinimumIdleSize()); if(StringUtils.isNotBlank(redssionProperties.getPassword())) { serverConfig.setPassword(redssionProperties.getPassword()); } return Redisson.create(config); }
Example 4
Source File: RedisInitializer.java From tio-starters with MIT License | 5 votes |
private Config getSingleServerConfig() { Config config = new Config(); String address = redisConfig.toString(); SingleServerConfig singleServerConfig = config.useSingleServer() .setAddress(address) .setConnectionPoolSize(redisConfig.getPoolSize()) .setConnectionMinimumIdleSize(redisConfig.getMinimumIdleSize()); if (redisConfig.hasPassword()) { singleServerConfig.setPassword(redisConfig.getPassword()); } config.setCodec(new FstCodec()); //默认情况下,看门狗的检查锁的超时时间是30秒钟 config.setLockWatchdogTimeout(1000 * 30); return config; }
Example 5
Source File: RedissonManager.java From SnowJena with Apache License 2.0 | 5 votes |
@Bean public RedissonClient redissonClient() { Config config = new Config(); SingleServerConfig singleServerConfig = config.useSingleServer() .setAddress("redis://" + redisProperties.getHost() + ":" + redisProperties.getPort()); if (redisProperties.getPassword() != null && !"".equals(redisProperties.getPassword())) { singleServerConfig.setPassword(redisProperties.getPassword()); } return Redisson.create(config); }
Example 6
Source File: RedissonAutoConfiguration.java From gpmall with Apache License 2.0 | 5 votes |
@Bean RedissonClient redissonClient() { Config config = new Config(); String node = redissonProperties.getAddress(); node = node.startsWith("redis://") ? node : "redis://" + node; SingleServerConfig serverConfig = config.useSingleServer() .setAddress(node) .setTimeout(redissonProperties.getTimeout()) .setConnectionMinimumIdleSize(redissonProperties.getPool().getMinIdle()); if (StringUtils.isNotBlank(redissonProperties.getPassword())) { serverConfig.setPassword(redissonProperties.getPassword()); } return Redisson.create(config); }
Example 7
Source File: RedisConfig.java From earth-frost with Apache License 2.0 | 5 votes |
/** * 单机模式 * * @param redissonProperties redisson配置 * @return client */ static RedissonClient redissonSingle(RedissonProperties redissonProperties) { Config config = new Config(); SingleServerConfig serverConfig = config.useSingleServer() .setAddress(redissonProperties.getAddress()).setTimeout(redissonProperties.getTimeout()) .setConnectionPoolSize(redissonProperties.getConnectionPoolSize()) .setConnectionMinimumIdleSize(redissonProperties.getConnectionMinimumIdleSize()); if (redissonProperties.getPassword() != null && redissonProperties.getPassword().length() > 0) { serverConfig.setPassword(redissonProperties.getPassword()); } return Redisson.create(config); }
Example 8
Source File: TokenServiceImpl.java From java-tutorial with MIT License | 5 votes |
public TokenServiceImpl() { Config config = new Config(); SingleServerConfig singleServerConfig = config.useSingleServer(); singleServerConfig.setAddress(redssionProperties.getAddress()); singleServerConfig.setPassword(redssionProperties.getPassword()); redissonClient = RedisUtils.getInstance().getRedisson(config); }
Example 9
Source File: SeedLockConfiguration.java From seed with Apache License 2.0 | 5 votes |
@PostConstruct public void initRedissonClientList(){ LogUtil.getLogger().info("RedissonClientList init beginning..."); //空判断:防止接入SpringCloud后二次初始化 if(!redissonClientList.isEmpty()){ LogUtil.getLogger().info("RedissonClientList has inited, skip..."); return; } for(String node : nodes){ Config config = new Config(); if(lockWatchdogTimeout > 0){ config.setLockWatchdogTimeout(lockWatchdogTimeout); } SingleServerConfig singleConfig = config.useSingleServer().setAddress(node); if(connectionMinimumIdleSize > 0){ singleConfig.setConnectionMinimumIdleSize(connectionMinimumIdleSize); } if(connectionPoolSize > 0){ singleConfig.setConnectionPoolSize(connectionPoolSize); } if(connectTimeout > 0){ singleConfig.setConnectTimeout(connectTimeout); } if(database > 0){ singleConfig.setDatabase(database); } if(StringUtils.isNotBlank(password)){ singleConfig.setPassword(password); } redissonClientList.add(Redisson.create(config)); LogUtil.getLogger().info("RedissonClientList init on {}", node); } LogUtil.getLogger().info("RedissonClientList init end..."); }
Example 10
Source File: RedisInitializer.java From t-io with Apache License 2.0 | 5 votes |
private Config getSingleServerConfig() { Config config = new Config(); String address = redisConfig.toString(); SingleServerConfig singleServerConfig = config.useSingleServer() .setAddress(address) .setConnectionPoolSize(redisConfig.getPoolSize()) .setConnectionMinimumIdleSize(redisConfig.getMinimumIdleSize()); if (redisConfig.hasPassword()) { singleServerConfig.setPassword(redisConfig.getPassword()); } config.setCodec(new FstCodec()); //默认情况下,看门狗的检查锁的超时时间是30秒钟 config.setLockWatchdogTimeout(1000 * 30); return config; }