Skip to content

Instantly share code, notes, and snippets.

@warpgate3
Created September 9, 2019 07:06
Show Gist options
  • Save warpgate3/5b794ebd524722abd4dda1b026258231 to your computer and use it in GitHub Desktop.
Save warpgate3/5b794ebd524722abd4dda1b026258231 to your computer and use it in GitHub Desktop.
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