Created
September 9, 2019 07:06
-
-
Save warpgate3/5b794ebd524722abd4dda1b026258231 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.m2sj.springfluxandredis; | |
import org.springframework.beans.factory.annotation.Value; | |
import org.springframework.context.annotation.Configuration; | |
import redis.embedded.RedisServer; | |
import javax.annotation.PostConstruct; | |
import javax.annotation.PreDestroy; | |
@Configuration | |
public class BasicEmbeddedRedisConfig { | |
@Value("${spring.redis.port}") | |
private int redisPort; | |
private RedisServer redisServer; | |
@PostConstruct | |
public void redisServer() { | |
redisServer = new RedisServer(redisPort); | |
redisServer.start(); | |
} | |
@PreDestroy | |
public void stopRedis() { | |
if (redisServer != null) { | |
redisServer.stop(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment