Giter Site home page Giter Site logo

bitthegeek / aredis Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 1.0 396 KB

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/

Shell 0.01% Java 99.99%

aredis's People

Contributors

msuresh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

scortes-prisma

aredis's Issues

ShardedExample not Sharding...?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.