forked from kstyrc/embedded-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRedisServer.java
More file actions
55 lines (46 loc) · 1.54 KB
/
RedisServer.java
File metadata and controls
55 lines (46 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package redis.embedded;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class RedisServer extends AbstractRedisInstance {
private static final String REDIS_READY_PATTERN = ".*The server is now ready to accept connections on port.*";
private static final int DEFAULT_REDIS_PORT = 6379;
public RedisServer() throws IOException {
this(DEFAULT_REDIS_PORT);
}
public RedisServer(int port) throws IOException {
super(port);
File executable = RedisExecProvider.defaultProvider().get();
this.args = Arrays.asList(
executable.getAbsolutePath(),
"--port", Integer.toString(port)
);
}
public RedisServer(File executable, int port) {
super(port);
this.args = Arrays.asList(
executable.getAbsolutePath(),
"--port", Integer.toString(port)
);
}
public RedisServer(RedisExecProvider redisExecProvider, int port) throws IOException {
super(port);
this.args = Arrays.asList(
redisExecProvider.get().getAbsolutePath(),
"--port", Integer.toString(port)
);
}
RedisServer(List<String> args, int port) {
super(port);
this.args = new ArrayList<String>(args);
}
public static RedisServerBuilder builder() {
return new RedisServerBuilder();
}
@Override
protected String redisReadyPattern() {
return REDIS_READY_PATTERN;
}
}