0
getRedisTemplate().executePipelined(
    new RedisCallback<Object>() { 
        @Override
        public Object doInRedis(RedisConnection connection) throws DataAccessException {
            connection.hGet(key);

            return null;
        }
    }
);

The result is null, and I can not fix it.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
nntk
  • 7
  • 2

1 Answers1

0

hGet return null when key or field do not exists or when used in pipeline / transaction.
Here it is.
You can use lua script instead.

String script = "local a = redis.call('hget','KEYS1','FIELD1')\n"+
                                        "if a then\n"+
                                        "   return redis.call('hincrby','KEYSAND'..a,'FIELD2',1)\n"+
                                        "end";
                                connection.eval(script.getBytes(), ReturnType.INTEGER, 0);
Hui Tan
  • 95
  • 1
  • 5