MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / GridRedisClient

Class GridRedisClient

java/src/org/openqa/selenium/redis/GridRedisClient.java:44–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42import org.redisson.config.SingleServerConfig;
43
44public class GridRedisClient implements Closeable {
45 private final RedisClient client;
46 private final RedissonClient redissonClient;
47 private final StatefulRedisConnection<String, String> connection;
48 private final RLiveObjectService service;
49
50 public GridRedisClient(URI serverUri) {
51 client = RedisClient.create(RedisURI.create(serverUri));
52 connection = client.connect();
53
54 Config redissonConfig = new Config();
55 redissonConfig.setNettyThreads(0);
56 SingleServerConfig singleServerConfig = redissonConfig.useSingleServer();
57 singleServerConfig.setAddress(serverUri.toString());
58 singleServerConfig.setConnectionMinimumIdleSize(5);
59 singleServerConfig.setConnectionPoolSize(5);
60 redissonClient = Redisson.create(redissonConfig);
61 service = redissonClient.getLiveObjectService();
62 }
63
64 public StatefulRedisConnection<String, String> getConnection() {
65 return connection;
66 }
67
68 public void mset(Map<String, String> map) {
69 connection.sync().mset(map);
70 }
71
72 public List<KeyValue<String, String>> mget(String... keys) {
73 return connection.sync().mget(keys);
74 }
75
76 @Nullable
77 public String get(String key) {
78 return connection.sync().get(key);
79 }
80
81 public List<String> getKeysByPattern(String pattern) {
82 return connection.sync().keys(pattern);
83 }
84
85 public void set(String key, String value) {
86 connection.sync().set(key, value);
87 }
88
89 public void setWithTtl(String key, String value, long ttlMillis) {
90 connection.sync().set(key, value, SetArgs.Builder.px(ttlMillis));
91 }
92
93 /** Returns true if the key was set (caller won the race), false if already present. */
94 public boolean setIfAbsent(String key, String value, long ttlMillis) {
95 String result = connection.sync().set(key, value, SetArgs.Builder.nx().px(ttlMillis));
96 return "OK".equals(result);
97 }
98
99 /** Returns true if the key was set (no TTL variant). */
100 public boolean setIfAbsent(String key, String value) {
101 String result = connection.sync().set(key, value, SetArgs.Builder.nx());

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected