bitthegeek / aredis Goto Github PK
View Code? Open in Web Editor NEWA java client for the Redis Cache server designed for performance and efficiency in terms of utilization of Connections and Threads
Home Page: http://aredis.sourceforge.net/
A java client for the Redis Cache server designed for performance and efficiency in terms of utilization of Connections and Threads
Home Page: http://aredis.sourceforge.net/
Hello, I'm attempting to use aredis to perform a sharded command against a simple Redis cluster.
I've setup the Redis Cluster according to https://redis.io/topics/cluster-tutorial and so have 6 nodes, 3 masters and 3 slaves.
I've then executed the example provided:
public static void main(String... args) throws ExecutionException, InterruptedException {
AsyncRedisClient aredis = getClient(null, "localhost:7000", "localhost:7001", "localhost:7002");
aredis.sendCommand(RedisCommand.SETEX, "hello0", "300", "world0");
aredis.sendCommand(RedisCommand.SETEX, "hello1", "300", "world1");
Future<RedisCommandInfo> future = aredis.submitCommand(RedisCommand.GET, "hello0");
// Deleting the above and non-existent keys
Future<RedisCommandInfo> future1 = aredis.submitCommand(RedisCommand.DEL, "hello0", "hello1", "hello2", "hello3", "hello4");
// Setting the values back in case you want to use redis-cli to check which key is in which DB
aredis.sendCommand(RedisCommand.SETEX, "hello0", "300", "world0");
aredis.sendCommand(RedisCommand.SETEX, "hello1", "300", "world1");
try {
String val = (String) future.get().getResult();
System.out.println("Got back val = " + val + " val1 = " + future1.get().getIntResult(-1));
}
catch(Exception e) {
e.printStackTrace();
}
}
public static AsyncRedisClient getClient(ExecutorService service, String... strings) {
AsyncRedisFactory f = new AsyncRedisFactory(service);
if (strings.length == 1) {
return f.getClient(strings[0]);
} else {
return f.getClient(Arrays.stream(strings).collect(Collectors.joining(",")));
}
}
However this results in an error because the server as responded with the MOVED response.
16:03:05.477 [pool-3-thread-2] INFO o.aredis.cache.AsyncRedisConnection - IDLING org.aredis.cache.AsyncRedisConnection@2ef1b168
16:03:05.477 [pool-3-thread-1] INFO o.aredis.cache.AsyncRedisConnection - IDLING org.aredis.cache.AsyncRedisConnection@7d1db6d9
16:03:05.477 [pool-3-thread-3] INFO o.aredis.cache.AsyncRedisConnection - IDLING org.aredis.cache.AsyncRedisConnection@4929cfe8
16:03:05.480 [pool-1-thread-1] INFO o.aredis.cache.AsyncRedisConnection - Trying to connect..
16:03:05.480 [pool-1-thread-1] INFO o.aredis.cache.AsyncRedisConnection - Connect Successful
16:03:05.480 [pool-1-thread-3] INFO o.aredis.cache.AsyncRedisConnection - Trying to connect..
16:03:05.480 [pool-1-thread-3] INFO o.aredis.cache.AsyncRedisConnection - Connect Successful
16:03:05.481 [pool-1-thread-2] INFO o.aredis.cache.AsyncRedisConnection - Trying to connect..
16:03:05.481 [pool-1-thread-2] INFO o.aredis.cache.AsyncRedisConnection - Connect Successful
java.lang.NumberFormatException: For input string: "MOVED 11613 127.0.0.1:7002"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at org.aredis.cache.RedisCommand$IntegerShardedResultHandler.aggregateResults(RedisCommand.java:268)
at org.aredis.cache.RedisCommandInfo.deserializeShardedCommandInfo(RedisCommandInfo.java:111)
at org.aredis.cache.RedisCommandInfo.deserialize(RedisCommandInfo.java:169)
at org.aredis.cache.RedisCommandInfo.getResult(RedisCommandInfo.java:248)
at org.aredis.cache.RedisCommandInfo.getIntResult(RedisCommandInfo.java:295)
at c.f.p.RedisTest.main(RedisTest.java:44)
Is this a feature that should be supported by the library or one that I need to implement myself? I ask because I assumed that the ShardedAsyncRedisClient would handle this automatically.
Redis Version:
12258:C 18 Dec 14:21:17.055 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
12258:C 18 Dec 14:21:17.056 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=12258, just started
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.