From 07698931c0abb4df71d3c88bea03e3cff0340e83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=9C=E7=9A=87=E5=A4=A7=E5=8F=94?= Date: Wed, 1 Jul 2020 19:22:03 +0800 Subject: [PATCH] add redisson --- cms/src/main/resources/application.properties | 6 +-- .../src/main/resources/application.properties | 6 +-- .../src/test/resources/application.properties | 6 +-- .../src/test/resources/application.properties | 6 +-- .../src/test/resources/application.properties | 5 +- lib/redis/raw/pom.xml | 24 ++++++---- .../resources/spring/spring-yo-redis-raw.xml | 46 +++++++++---------- .../yo/redis/raw/RawRedisClientTest.java | 22 ++++++++- .../pudonghot/yo/redis/raw/TestDriver.java | 23 ++++++++++ .../src/test/resources/application.properties | 8 ++-- .../src/test/resources/application.properties | 5 +- .../src/main/resources/application.properties | 6 +-- 12 files changed, 103 insertions(+), 60 deletions(-) create mode 100644 lib/redis/raw/src/test/java/com/pudonghot/yo/redis/raw/TestDriver.java diff --git a/cms/src/main/resources/application.properties b/cms/src/main/resources/application.properties index ee14fbb6..51dac7c3 100644 --- a/cms/src/main/resources/application.properties +++ b/cms/src/main/resources/application.properties @@ -21,9 +21,9 @@ yo.fs.datasource.username=freeswitch yo.fs.datasource.password=RR!h5IpirsnJ # Redis -yo.redis.host=172.16.92.232 -yo.redis.port=6379 -yo.redis.password=123456 +spring.redis.host=172.16.92.232 +spring.redis.port=6379 +spring.redis.password=123456 # CAS tigon.shiro.cas.server.addr=https://cas.wacai.com diff --git a/fsagent/src/main/resources/application.properties b/fsagent/src/main/resources/application.properties index 28c0eb07..ffcc14d3 100644 --- a/fsagent/src/main/resources/application.properties +++ b/fsagent/src/main/resources/application.properties @@ -19,9 +19,9 @@ yo.fs.datasource.username=freeswitch yo.fs.datasource.password=RR!h5IpirsnJ # Redis -yo.redis.host=172.16.92.232 -yo.redis.port=6379 -yo.redis.password=123456 +spring.redis.host=172.16.92.232 +spring.redis.port=6379 +spring.redis.password=123456 # Dubbo diff --git a/lib/mapper/src/test/resources/application.properties b/lib/mapper/src/test/resources/application.properties index d2985950..275a1367 100644 --- a/lib/mapper/src/test/resources/application.properties +++ b/lib/mapper/src/test/resources/application.properties @@ -6,6 +6,6 @@ yo.datasource.username=yoqw yo.datasource.password=yoqw_query! # Redis -yo.redis.host=172.16.92.232 -yo.redis.port=6379 -yo.redis.password=123456 +spring.redis.host=172.16.92.232 +spring.redis.port=6379 +spring.redis.password=123456 diff --git a/lib/mybatis-cache/src/test/resources/application.properties b/lib/mybatis-cache/src/test/resources/application.properties index f58bbfba..2a1ee2e3 100644 --- a/lib/mybatis-cache/src/test/resources/application.properties +++ b/lib/mybatis-cache/src/test/resources/application.properties @@ -1,7 +1,7 @@ spring.application.name=yo-mybatis-cache # Redis -yo.redis.host=172.16.92.232 -yo.redis.port=6379 -yo.redis.password=123456 +spring.redis.host=172.16.92.232 +spring.redis.port=6379 +spring.redis.password=123456 diff --git a/lib/redis/api/src/test/resources/application.properties b/lib/redis/api/src/test/resources/application.properties index e69caf13..ad6c4020 100644 --- a/lib/redis/api/src/test/resources/application.properties +++ b/lib/redis/api/src/test/resources/application.properties @@ -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 diff --git a/lib/redis/raw/pom.xml b/lib/redis/raw/pom.xml index 86cb7b1f..7c8d81eb 100644 --- a/lib/redis/raw/pom.xml +++ b/lib/redis/raw/pom.xml @@ -33,6 +33,11 @@ org.springframework.data spring-data-redis + + org.redisson + redisson-spring-boot-starter + 3.13.1 + org.projectlombok lombok @@ -45,18 +50,19 @@ test - org.springframework - spring-test + org.springframework.boot + spring-boot-starter-test test + + + spring-boot-starter-logging + org.springframework.boot + + - org.apache.logging.log4j - log4j-slf4j-impl - test - - - org.apache.logging.log4j - log4j-core + org.springframework.boot + spring-boot-starter-log4j2 test diff --git a/lib/redis/raw/src/main/resources/spring/spring-yo-redis-raw.xml b/lib/redis/raw/src/main/resources/spring/spring-yo-redis-raw.xml index 22f73af2..79ca26ed 100644 --- a/lib/redis/raw/src/main/resources/spring/spring-yo-redis-raw.xml +++ b/lib/redis/raw/src/main/resources/spring/spring-yo-redis-raw.xml @@ -9,31 +9,31 @@ + p:host-name="${spring.redis.host:localhost}" + p:port="${spring.redis.port:6379}" + p:password="${spring.redis.password:#{null}}" + p:database="${spring.redis.database:0}"> diff --git a/lib/redis/raw/src/test/java/com/pudonghot/yo/redis/raw/RawRedisClientTest.java b/lib/redis/raw/src/test/java/com/pudonghot/yo/redis/raw/RawRedisClientTest.java index 2b89247f..b9268684 100644 --- a/lib/redis/raw/src/test/java/com/pudonghot/yo/redis/raw/RawRedisClientTest.java +++ b/lib/redis/raw/src/test/java/com/pudonghot/yo/redis/raw/RawRedisClientTest.java @@ -1,11 +1,14 @@ package com.pudonghot.yo.redis.raw; import org.junit.Test; +import lombok.SneakyThrows; import org.junit.runner.RunWith; import lombok.extern.slf4j.Slf4j; +import org.redisson.api.RBlockingQueue; +import org.redisson.api.RedissonClient; import com.pudonghot.yo.redis.RedisClientApi; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** @@ -13,11 +16,13 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * Jun 19, 2017 16:53 */ @Slf4j +@SpringBootTest(classes = TestDriver.class) @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("classpath*:spring/spring-*.xml") public class RawRedisClientTest { @Autowired private RedisClientApi redisClient; + @Autowired + private RedissonClient redisson; @Test public void testRun() { @@ -26,4 +31,17 @@ public class RawRedisClientTest { log.info("Get [{}] from redis result [{}].", key, redisClient.get(key)); log.info("Delete [{}] from redis result [{}].", key, redisClient.del(key)); } + + @Test + @SneakyThrows + public void testQueue() { + final RBlockingQueue 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()); + } } diff --git a/lib/redis/raw/src/test/java/com/pudonghot/yo/redis/raw/TestDriver.java b/lib/redis/raw/src/test/java/com/pudonghot/yo/redis/raw/TestDriver.java new file mode 100644 index 00000000..d94f090d --- /dev/null +++ b/lib/redis/raw/src/test/java/com/pudonghot/yo/redis/raw/TestDriver.java @@ -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
+ * 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); + } +} diff --git a/lib/redis/raw/src/test/resources/application.properties b/lib/redis/raw/src/test/resources/application.properties index 3b613ace..5952de3c 100644 --- a/lib/redis/raw/src/test/resources/application.properties +++ b/lib/redis/raw/src/test/resources/application.properties @@ -1,6 +1,8 @@ spring.application.name=yo-redis-raw # Redis -yo.redis.host=172.16.92.232 -yo.redis.port=6379 -yo.redis.password=123456 +spring.redis.host=172.16.92.232 +spring.redis.port=6379 +spring.redis.password=123456 +spring.redis.database=0 + diff --git a/lib/shiro-cache/src/test/resources/application.properties b/lib/shiro-cache/src/test/resources/application.properties index 689d82b4..f3d3d7c8 100644 --- a/lib/shiro-cache/src/test/resources/application.properties +++ b/lib/shiro-cache/src/test/resources/application.properties @@ -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 diff --git a/openapi/src/main/resources/application.properties b/openapi/src/main/resources/application.properties index 9dbf9897..1722aa72 100644 --- a/openapi/src/main/resources/application.properties +++ b/openapi/src/main/resources/application.properties @@ -16,9 +16,9 @@ yo.datasource.username=yoqw yo.datasource.password=yoqw_query! # Redis -yo.redis.host=172.16.92.232 -yo.redis.port=6379 -yo.redis.password=123456 +spring.redis.host=172.16.92.232 +spring.redis.port=6379 +spring.redis.password=123456 # Shiro tigon.shiro.filter-chain=/v1/auth/sign-in=anon \