Skip to content

Commit ba5858d

Browse files
authored
Create Redis_KeyValueMap_test.java
1 parent a7e6e93 commit ba5858d

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package picoded.dstack.redis;
2+
3+
import picoded.core.struct.*;
4+
import picoded.dstack.*;
5+
import picoded.dstack.struct.simple.*;
6+
7+
import java.util.concurrent.ThreadLocalRandom;
8+
9+
10+
public class RedisKeyValueMap_test extends StructSimple_KeyValueMap_test {
11+
// Redis stack instance
12+
protected static volatile RedisStack instance = null;
13+
14+
/// Implementation constructor
15+
public KeyValueMap implementationConstructor() {
16+
17+
// Initialize server
18+
synchronized (RedisKeyValueMap_test.class) {
19+
if (instance == null) {
20+
// The default config uses "172.17.0.1" (default docker bridge address)
21+
// and port 6379 (default redis port)
22+
GenericConvertMap<String, Object> redisConfig = new GenericConvertHashMap<>();
23+
redisConfig.put("host", DStackTestConfig.REDIS_HOST());
24+
redisConfig.put("port", DStackTestConfig.REDIS_PORT());
25+
26+
// Use a random DB number between 0 and 15.
27+
// int randomNum = ThreadLocalRandom.current().nextInt(0, 15 + 1);
28+
redisConfig.put("name", DStackTestConfig.randomTablePrefix());
29+
30+
GenericConvertMap<String, Object> stackConfig = new GenericConvertHashMap<>();
31+
stackConfig.put("name", "RedisKeyValueMap_test");
32+
stackConfig.put("redis", redisConfig);
33+
34+
instance = new RedisStack(stackConfig);
35+
}
36+
}
37+
// Load the KeyValueMap
38+
return instance.keyValueMap(DStackTestConfig.randomTablePrefix());
39+
}
40+
}

0 commit comments

Comments
 (0)