A tiny redis embedded server fully integrated with Spring and Spring Boot, Only for testing or debugging.
- Spring 3.1 +
- JDK 1.6 +
Note: this step is optional, Can be able to fetch the dependencies directly from Central.
git clone https://github.com/caryyu/spring-embedded-redis-server
mvn install
<dependency>
<groupId>com.github.caryyu</groupId>
<artifactId>spring-embedded-redis-server</artifactId>
<version>1.0</version>
</dependency>
We can pass the configuration as the following
Note: we just only need to choose one of following three ones to pass.
the package of com.github.caryyu
is must.
<context:component-scan base-package="com.github.caryyu,xxxx" />
the xml filename based on your real situation.
<beans:bean class="com.github.caryyu.spring.embedded.redisserver.RedisServerConfiguration" id="redisServerConfiguration" />
@Bean
public RedisServerConfiguration redisServerConfiguration(){
return new RedisServerConfiguration();
}
Here's two core variables to use.
- global.redis.port - this is the embedded port for server listening.
- global.redis.embedded - this is the switch to check whether or not it is ON/OFF.
Actually , we have lots of ways to use this library, ofcourse i really recommend you according to Spring official Environment Variables,so i just give some usages below.
java -Dspring.redis.embedded=true
we need to modify catalina.sh or catalina.bat or add new file that can name setenv.sh
etc.
set JAVA_OPTS="-Dspring.redis.embedded=true"
spring.redis.port=6379
spring.redis.embedded=true
spring:
redis:
port: 6379
embedded: true
All Contributions are welcomed.