add redisson

This commit is contained in:
东皇大叔 2020-07-01 19:22:03 +08:00
parent 39147d580f
commit 07698931c0
12 changed files with 103 additions and 60 deletions

View File

@ -21,9 +21,9 @@ yo.fs.datasource.username=freeswitch
yo.fs.datasource.password=RR!h5IpirsnJ yo.fs.datasource.password=RR!h5IpirsnJ
# Redis # Redis
yo.redis.host=172.16.92.232 spring.redis.host=172.16.92.232
yo.redis.port=6379 spring.redis.port=6379
yo.redis.password=123456 spring.redis.password=123456
# CAS # CAS
tigon.shiro.cas.server.addr=https://cas.wacai.com tigon.shiro.cas.server.addr=https://cas.wacai.com

View File

@ -19,9 +19,9 @@ yo.fs.datasource.username=freeswitch
yo.fs.datasource.password=RR!h5IpirsnJ yo.fs.datasource.password=RR!h5IpirsnJ
# Redis # Redis
yo.redis.host=172.16.92.232 spring.redis.host=172.16.92.232
yo.redis.port=6379 spring.redis.port=6379
yo.redis.password=123456 spring.redis.password=123456
# Dubbo # Dubbo

View File

@ -6,6 +6,6 @@ yo.datasource.username=yoqw
yo.datasource.password=yoqw_query! yo.datasource.password=yoqw_query!
# Redis # Redis
yo.redis.host=172.16.92.232 spring.redis.host=172.16.92.232
yo.redis.port=6379 spring.redis.port=6379
yo.redis.password=123456 spring.redis.password=123456

View File

@ -1,7 +1,7 @@
spring.application.name=yo-mybatis-cache spring.application.name=yo-mybatis-cache
# Redis # Redis
yo.redis.host=172.16.92.232 spring.redis.host=172.16.92.232
yo.redis.port=6379 spring.redis.port=6379
yo.redis.password=123456 spring.redis.password=123456

View File

@ -1,5 +1,2 @@
spring.application.name=YO_REDIS spring.application.name=yo-redis
# Redis Cluster
yo.redis-cluster.app-id=10003
yo.redis-cluster.app-key=d7317ef13ea37c03f87fcd214755b341

View File

@ -33,6 +33,11 @@
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId> <artifactId>spring-data-redis</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.13.1</version>
</dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
@ -45,18 +50,19 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.logging.log4j</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>log4j-slf4j-impl</artifactId> <artifactId>spring-boot-starter-log4j2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -9,31 +9,31 @@
<!-- Redis Tpl --> <!-- Redis Tpl -->
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" <bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:host-name="${yo.redis.host}" p:host-name="${spring.redis.host:localhost}"
p:port="${yo.redis.port:6379}" p:port="${spring.redis.port:6379}"
p:password="${yo.redis.password:#{null}}" p:password="${spring.redis.password:#{null}}"
p:database="${yo.redis.database:0}"> p:database="${spring.redis.database:0}">
<constructor-arg> <constructor-arg>
<bean class="redis.clients.jedis.JedisPoolConfig" <bean class="redis.clients.jedis.JedisPoolConfig"
p:maxTotal="${yo.redis.max-total:8}" p:maxTotal="${spring.redis.pool.max-total:8}"
p:maxIdle="${yo.redis.max-idle:8}" p:maxIdle="${spring.redis.pool.max-idle:8}"
p:minIdle="${yo.redis.min-idle:0}" p:minIdle="${spring.redis.pool.min-idle:0}"
p:testWhileIdle="${yo.redis.test-while-idle:true}" p:testWhileIdle="${spring.redis.pool.test-while-idle:true}"
p:maxWaitMillis="${yo.redis.max-wait-millis:-1}" p:maxWaitMillis="${spring.redis.pool.max-wait-millis:-1}"
p:blockWhenExhausted="${yo.redis.block-when-exhausted:true}" p:blockWhenExhausted="${spring.redis.pool.block-when-exhausted:true}"
p:testOnBorrow="${yo.redis.test-on-borrow:false}" p:testOnBorrow="${spring.redis.pool.test-on-borrow:false}"
p:testOnCreate="${yo.redis.test-on-create:false}" p:testOnCreate="${spring.redis.pool.test-on-create:false}"
p:testOnReturn="${yo.redis.test-on-return:false}" p:testOnReturn="${spring.redis.pool.test-on-return:false}"
p:numTestsPerEvictionRun="${yo.redis.num-tests-per-eviction-run:3}" p:numTestsPerEvictionRun="${spring.redis.pool.num-tests-per-eviction-run:3}"
p:evictionPolicyClassName="${yo.redis.eviction-policy-class-name:org.apache.commons.pool2.impl.DefaultEvictionPolicy}" p:evictionPolicyClassName="${spring.redis.pool.eviction-policy-class-name:org.apache.commons.pool2.impl.DefaultEvictionPolicy}"
p:fairness="${yo.redis.fairness:false}" p:fairness="${spring.redis.pool.fairness:false}"
p:jmxEnabled="${yo.redis.jmx-enabled:true}" p:jmxEnabled="${spring.redis.pool.jmx-enabled:true}"
p:lifo="${yo.redis.lifo:true}" p:lifo="${spring.redis.pool.lifo:true}"
p:minEvictableIdleTimeMillis="${yo.redis.min-evictable-idle-time-millis:1800000}" p:minEvictableIdleTimeMillis="${spring.redis.pool.min-evictable-idle-time-millis:1800000}"
p:softMinEvictableIdleTimeMillis="${yo.redis.soft-min-evictable-idle-time-millis:1800000}" p:softMinEvictableIdleTimeMillis="${spring.redis.pool.soft-min-evictable-idle-time-millis:1800000}"
p:timeBetweenEvictionRunsMillis="${yo.redis.time-between-eviction-runs-millis:-1}" p:timeBetweenEvictionRunsMillis="${spring.redis.pool.time-between-eviction-runs-millis:-1}"
p:jmxNameBase="${yo.redis.jmx-name-base:#{null}}" p:jmxNameBase="${spring.redis.pool.jmx-name-base:#{null}}"
p:jmxNamePrefix="${yo.redis.jmx-name-prefix:pool}" p:jmxNamePrefix="${spring.redis.pool.jmx-name-prefix:pool}"
/> />
</constructor-arg> </constructor-arg>
</bean> </bean>

View File

@ -1,11 +1,14 @@
package com.pudonghot.yo.redis.raw; package com.pudonghot.yo.redis.raw;
import org.junit.Test; import org.junit.Test;
import lombok.SneakyThrows;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RBlockingQueue;
import org.redisson.api.RedissonClient;
import com.pudonghot.yo.redis.RedisClientApi; import com.pudonghot.yo.redis.RedisClientApi;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/** /**
@ -13,11 +16,13 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* Jun 19, 2017 16:53 * Jun 19, 2017 16:53
*/ */
@Slf4j @Slf4j
@SpringBootTest(classes = TestDriver.class)
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath*:spring/spring-*.xml")
public class RawRedisClientTest { public class RawRedisClientTest {
@Autowired @Autowired
private RedisClientApi redisClient; private RedisClientApi redisClient;
@Autowired
private RedissonClient redisson;
@Test @Test
public void testRun() { public void testRun() {
@ -26,4 +31,17 @@ public class RawRedisClientTest {
log.info("Get [{}] from redis result [{}].", key, redisClient.get(key)); log.info("Get [{}] from redis result [{}].", key, redisClient.get(key));
log.info("Delete [{}] from redis result [{}].", key, redisClient.del(key)); log.info("Delete [{}] from redis result [{}].", key, redisClient.del(key));
} }
@Test
@SneakyThrows
public void testQueue() {
final RBlockingQueue<Object> queue = redisson.getBlockingQueue("anyQueue");
queue.offer("1");
queue.offer("2");
queue.offer("3");
log.info("Val1 [{}].", queue.poll());
log.info("Val2 [{}].", queue.poll());
log.info("Val3 [{}].", queue.poll());
log.info("Val4 [{}].", queue.take());
}
} }

View File

@ -0,0 +1,23 @@
package com.pudonghot.yo.redis.raw;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.ImportResource;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author Donghuang <br>
* Jun 19, 2017 16:53
*/
@Slf4j
@SpringBootApplication
@ImportResource("classpath*:spring/spring-*.xml")
public class TestDriver {
/**
* main
*/
public static void main(String[] args) {
SpringApplication.run(TestDriver.class, args);
}
}

View File

@ -1,6 +1,8 @@
spring.application.name=yo-redis-raw spring.application.name=yo-redis-raw
# Redis # Redis
yo.redis.host=172.16.92.232 spring.redis.host=172.16.92.232
yo.redis.port=6379 spring.redis.port=6379
yo.redis.password=123456 spring.redis.password=123456
spring.redis.database=0

View File

@ -1,5 +1,2 @@
spring.application.name=Yo_MyBatis_Cache spring.application.name=yo-mybatis-cache
#redis cluster
yo.redis-cluster.app-id=10003
yo.redis-cluster.app-key=d7317ef13ea37c03f87fcd214755b341

View File

@ -16,9 +16,9 @@ yo.datasource.username=yoqw
yo.datasource.password=yoqw_query! yo.datasource.password=yoqw_query!
# Redis # Redis
yo.redis.host=172.16.92.232 spring.redis.host=172.16.92.232
yo.redis.port=6379 spring.redis.port=6379
yo.redis.password=123456 spring.redis.password=123456
# Shiro # Shiro
tigon.shiro.filter-chain=/v1/auth/sign-in=anon \ tigon.shiro.filter-chain=/v1/auth/sign-in=anon \