Fixed - Spring Data Redis evalsha doesn't use key for Redis node routing in Cluster mode. #4561

pull/4550/merge
Nikita Koksharov 2 years ago
parent e6e961f127
commit 91268be8ab

@ -1765,7 +1765,9 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(script);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
protected RedisCommand<?> toCommand(ReturnType returnType, String name) {
@ -1800,7 +1802,9 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
@Override
@ -1810,7 +1814,16 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
private static byte[] getKey(int numKeys, byte[][] keysAndArgs) {
if (numKeys > 0 && keysAndArgs.length > 0) {
return keysAndArgs[0];
}
return null;
}
private static final RedisCommand<Long> PFADD = new RedisCommand<Long>("PFADD");

@ -1819,11 +1819,13 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(script);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
protected RedisCommand<?> toCommand(ReturnType returnType, String name) {
RedisCommand<?> c = null;
RedisCommand<?> c = null;
if (returnType == ReturnType.BOOLEAN) {
c = org.redisson.api.RScript.ReturnType.BOOLEAN.getCommand();
} else if (returnType == ReturnType.INTEGER) {
@ -1854,7 +1856,9 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
@Override
@ -1864,7 +1868,16 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
private static byte[] getKey(int numKeys, byte[][] keysAndArgs) {
if (numKeys > 0 && keysAndArgs.length > 0) {
return keysAndArgs[0];
}
return null;
}
private static final RedisCommand<Long> PFADD = new RedisCommand<Long>("PFADD");

@ -1832,11 +1832,13 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(script);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
protected RedisCommand<?> toCommand(ReturnType returnType, String name) {
RedisCommand<?> c = null;
RedisCommand<?> c = null;
if (returnType == ReturnType.BOOLEAN) {
c = org.redisson.api.RScript.ReturnType.BOOLEAN.getCommand();
} else if (returnType == ReturnType.INTEGER) {
@ -1867,7 +1869,9 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
@Override
@ -1877,7 +1881,16 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
private static byte[] getKey(int numKeys, byte[][] keysAndArgs) {
if (numKeys > 0 && keysAndArgs.length > 0) {
return keysAndArgs[0];
}
return null;
}
@Override

@ -1835,11 +1835,13 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(script);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
protected RedisCommand<?> toCommand(ReturnType returnType, String name) {
RedisCommand<?> c = null;
RedisCommand<?> c = null;
if (returnType == ReturnType.BOOLEAN) {
c = org.redisson.api.RScript.ReturnType.BOOLEAN.getCommand();
} else if (returnType == ReturnType.INTEGER) {
@ -1870,7 +1872,9 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
@Override
@ -1880,7 +1884,16 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
private static byte[] getKey(int numKeys, byte[][] keysAndArgs) {
if (numKeys > 0 && keysAndArgs.length > 0) {
return keysAndArgs[0];
}
return null;
}
@Override

@ -1838,11 +1838,13 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(script);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
protected RedisCommand<?> toCommand(ReturnType returnType, String name) {
RedisCommand<?> c = null;
RedisCommand<?> c = null;
if (returnType == ReturnType.BOOLEAN) {
c = org.redisson.api.RScript.ReturnType.BOOLEAN.getCommand();
} else if (returnType == ReturnType.INTEGER) {
@ -1873,7 +1875,9 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
@Override
@ -1883,7 +1887,16 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
private static byte[] getKey(int numKeys, byte[][] keysAndArgs) {
if (numKeys > 0 && keysAndArgs.length > 0) {
return keysAndArgs[0];
}
return null;
}
@Override

@ -1838,11 +1838,13 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(script);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
protected RedisCommand<?> toCommand(ReturnType returnType, String name) {
RedisCommand<?> c = null;
RedisCommand<?> c = null;
if (returnType == ReturnType.BOOLEAN) {
c = org.redisson.api.RScript.ReturnType.BOOLEAN.getCommand();
} else if (returnType == ReturnType.INTEGER) {
@ -1873,7 +1875,9 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
@Override
@ -1883,7 +1887,16 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
private static byte[] getKey(int numKeys, byte[][] keysAndArgs) {
if (numKeys > 0 && keysAndArgs.length > 0) {
return keysAndArgs[0];
}
return null;
}
@Override

@ -1838,11 +1838,13 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(script);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
protected RedisCommand<?> toCommand(ReturnType returnType, String name) {
RedisCommand<?> c = null;
RedisCommand<?> c = null;
if (returnType == ReturnType.BOOLEAN) {
c = org.redisson.api.RScript.ReturnType.BOOLEAN.getCommand();
} else if (returnType == ReturnType.INTEGER) {
@ -1873,7 +1875,9 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
@Override
@ -1883,7 +1887,16 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
private static byte[] getKey(int numKeys, byte[][] keysAndArgs) {
if (numKeys > 0 && keysAndArgs.length > 0) {
return keysAndArgs[0];
}
return null;
}
@Override

@ -1863,11 +1863,13 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(script);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
protected RedisCommand<?> toCommand(ReturnType returnType, String name) {
RedisCommand<?> c = null;
RedisCommand<?> c = null;
if (returnType == ReturnType.BOOLEAN) {
c = org.redisson.api.RScript.ReturnType.BOOLEAN.getCommand();
} else if (returnType == ReturnType.INTEGER) {
@ -1898,7 +1900,9 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
@Override
@ -1908,7 +1912,16 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
private static byte[] getKey(int numKeys, byte[][] keysAndArgs) {
if (numKeys > 0 && keysAndArgs.length > 0) {
return keysAndArgs[0];
}
return null;
}
@Override

@ -1902,11 +1902,13 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(script);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
protected RedisCommand<?> toCommand(ReturnType returnType, String name) {
RedisCommand<?> c = null;
RedisCommand<?> c = null;
if (returnType == ReturnType.BOOLEAN) {
c = org.redisson.api.RScript.ReturnType.BOOLEAN.getCommand();
} else if (returnType == ReturnType.INTEGER) {
@ -1937,7 +1939,9 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
@Override
@ -1947,7 +1951,16 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
private static byte[] getKey(int numKeys, byte[][] keysAndArgs) {
if (numKeys > 0 && keysAndArgs.length > 0) {
return keysAndArgs[0];
}
return null;
}
@Override

@ -1907,11 +1907,13 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(script);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
protected RedisCommand<?> toCommand(ReturnType returnType, String name) {
RedisCommand<?> c = null;
RedisCommand<?> c = null;
if (returnType == ReturnType.BOOLEAN) {
c = org.redisson.api.RScript.ReturnType.BOOLEAN.getCommand();
} else if (returnType == ReturnType.INTEGER) {
@ -1942,7 +1944,9 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
@Override
@ -1952,7 +1956,16 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
private static byte[] getKey(int numKeys, byte[][] keysAndArgs) {
if (numKeys > 0 && keysAndArgs.length > 0) {
return keysAndArgs[0];
}
return null;
}
@Override

@ -1907,11 +1907,13 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(script);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
protected RedisCommand<?> toCommand(ReturnType returnType, String name) {
RedisCommand<?> c = null;
RedisCommand<?> c = null;
if (returnType == ReturnType.BOOLEAN) {
c = org.redisson.api.RScript.ReturnType.BOOLEAN.getCommand();
} else if (returnType == ReturnType.INTEGER) {
@ -1942,7 +1944,9 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
@Override
@ -1952,7 +1956,16 @@ public class RedissonConnection extends AbstractRedisConnection {
params.add(scriptSha);
params.add(numKeys);
params.addAll(Arrays.asList(keysAndArgs));
return write(null, ByteArrayCodec.INSTANCE, c, params.toArray());
byte[] key = getKey(numKeys, keysAndArgs);
return write(key, ByteArrayCodec.INSTANCE, c, params.toArray());
}
private static byte[] getKey(int numKeys, byte[][] keysAndArgs) {
if (numKeys > 0 && keysAndArgs.length > 0) {
return keysAndArgs[0];
}
return null;
}
@Override

Loading…
Cancel
Save