til
til copied to clipboard
Windows 에서 Embedded Redis 실행시 에러가 발생할 경우
- 포트가 사용중일 경우 : 컴퓨터를 재시작하는게 제일 빠름
- 메모리 설정이 없을 경우 :
setting("maxmemory 128M")
코드를 추가함
// https://github.com/kstyrc/embedded-redis/issues/51#issuecomment-318221233
@Configuration
@Profile("test")
public class EmbeddedRedisServer {
@Value("${spring.redis.port:6380}")
private int redisPort;
private RedisServer redisServer;
@PostConstruct
public void startRedis() throws IOException, URISyntaxException {
//redisPort = org.springframework.util.SocketUtils.findAvailableTcpPort(6380);
//RedisExecProvider customRedisExec = RedisExecProvider.defaultProvider().override
// (OsArchitecture.detect().os(), OsArchitecture.detect().arch(), "redis-server-2.8.19.exe");
redisServer = RedisServer.builder()
.port(redisPort)
//.redisExecProvider(customRedisExec) //com.github.kstyrc (not com.orange.redis-embedded)
.setting("maxmemory 128M") //maxheap 128M
.build();
redisServer.start();
}
@PreDestroy
public void stopRedis() throws InterruptedException {
if (redisServer != null) {
redisServer.stop();
}
}
}