diff --git a/src/main/java/io/vertx/redis/client/Command.java b/src/main/java/io/vertx/redis/client/Command.java
index 8d3c1245..1379b44f 100644
--- a/src/main/java/io/vertx/redis/client/Command.java
+++ b/src/main/java/io/vertx/redis/client/Command.java
@@ -24,7 +24,7 @@
* Auto generated API Commands to interact with REDIS.
*
* @author Paulo Lopes
- * @version redis_version:7.0.0
+ * @version redis_version:7.0.12
*/
@VertxGen
public interface Command {
@@ -34,6 +34,7 @@ public interface Command {
Command ASKING = new CommandImpl("asking", 1, null, false, false);
Command AUTH = new CommandImpl("auth", -2, null, false, false);
Command BF_ADD = new CommandImpl("bf.add", -1, false, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
+ Command BF_CARD = new CommandImpl("bf.card", -1, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
Command BF_DEBUG = new CommandImpl("bf.debug", -1, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
Command BF_EXISTS = new CommandImpl("bf.exists", -1, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
Command BF_INFO = new CommandImpl("bf.info", -1, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
@@ -93,8 +94,8 @@ public interface Command {
Command ECHO = new CommandImpl("echo", 2, null, false, false);
Command EVAL = new CommandImpl("eval", -3, null, false, false, new KeyLocator(false, new BeginSearchIndex(2), new FindKeysKeynum(0, 1, 1)));
Command EVALSHA = new CommandImpl("evalsha", -3, null, false, false, new KeyLocator(false, new BeginSearchIndex(2), new FindKeysKeynum(0, 1, 1)));
- Command EVALSHA_RO = new CommandImpl("evalsha_ro", -3, null, false, false, new KeyLocator(true, new BeginSearchIndex(2), new FindKeysKeynum(0, 1, 1)));
- Command EVAL_RO = new CommandImpl("eval_ro", -3, null, false, false, new KeyLocator(true, new BeginSearchIndex(2), new FindKeysKeynum(0, 1, 1)));
+ Command EVALSHA_RO = new CommandImpl("evalsha_ro", -3, true, false, false, new KeyLocator(true, new BeginSearchIndex(2), new FindKeysKeynum(0, 1, 1)));
+ Command EVAL_RO = new CommandImpl("eval_ro", -3, true, false, false, new KeyLocator(true, new BeginSearchIndex(2), new FindKeysKeynum(0, 1, 1)));
Command EXEC = new CommandImpl("exec", 1, null, false, false);
Command EXISTS = new CommandImpl("exists", -2, true, false, false, new KeyLocator(true, new BeginSearchIndex(1), new FindKeysRange(-1, 1, 0)));
Command EXPIRE = new CommandImpl("expire", -3, false, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
@@ -102,7 +103,7 @@ public interface Command {
Command EXPIRETIME = new CommandImpl("expiretime", 2, true, false, false, new KeyLocator(true, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
Command FAILOVER = new CommandImpl("failover", -1, null, false, false);
Command FCALL = new CommandImpl("fcall", -3, null, false, false, new KeyLocator(false, new BeginSearchIndex(2), new FindKeysKeynum(0, 1, 1)));
- Command FCALL_RO = new CommandImpl("fcall_ro", -3, null, false, false, new KeyLocator(true, new BeginSearchIndex(2), new FindKeysKeynum(0, 1, 1)));
+ Command FCALL_RO = new CommandImpl("fcall_ro", -3, true, false, false, new KeyLocator(true, new BeginSearchIndex(2), new FindKeysKeynum(0, 1, 1)));
Command FLUSHALL = new CommandImpl("flushall", -1, false, false, false);
Command FLUSHDB = new CommandImpl("flushdb", -1, false, false, false);
Command FT_ADD = new CommandImpl("FT.ADD", -1, false, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(1, 1, 0)));
@@ -250,7 +251,7 @@ public interface Command {
Command PEXPIRETIME = new CommandImpl("pexpiretime", 2, true, false, false, new KeyLocator(true, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
Command PFADD = new CommandImpl("pfadd", -2, false, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
Command PFCOUNT = new CommandImpl("pfcount", -2, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(-1, 1, 0)));
- Command PFDEBUG = new CommandImpl("pfdebug", -3, false, false, false, new KeyLocator(false, new BeginSearchIndex(2), new FindKeysRange(0, 1, 0)));
+ Command PFDEBUG = new CommandImpl("pfdebug", 3, false, false, false, new KeyLocator(false, new BeginSearchIndex(2), new FindKeysRange(0, 1, 0)));
Command PFMERGE = new CommandImpl("pfmerge", -2, false, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)), new KeyLocator(true, new BeginSearchIndex(2), new FindKeysRange(-1, 1, 0)));
Command PFSELFTEST = new CommandImpl("pfselftest", 1, null, false, false);
Command PING = new CommandImpl("ping", -1, null, false, false);
@@ -316,6 +317,20 @@ public interface Command {
Command SUNSUBSCRIBE = new CommandImpl("sunsubscribe", -1, null, true, false, new KeyLocator(null, new BeginSearchIndex(1), new FindKeysRange(-1, 1, 0)));
Command SWAPDB = new CommandImpl("swapdb", 3, false, false, false);
Command SYNC = new CommandImpl("sync", 1, null, false, false);
+ Command TDIGEST_ADD = new CommandImpl("tdigest.add", -1, false, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
+ Command TDIGEST_BYRANK = new CommandImpl("tdigest.byrank", -1, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
+ Command TDIGEST_BYREVRANK = new CommandImpl("tdigest.byrevrank", -1, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
+ Command TDIGEST_CDF = new CommandImpl("tdigest.cdf", -1, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
+ Command TDIGEST_CREATE = new CommandImpl("tdigest.create", -1, false, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
+ Command TDIGEST_INFO = new CommandImpl("tdigest.info", -1, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
+ Command TDIGEST_MAX = new CommandImpl("tdigest.max", -1, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
+ Command TDIGEST_MERGE = new CommandImpl("tdigest.merge", -1, false, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
+ Command TDIGEST_MIN = new CommandImpl("tdigest.min", -1, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
+ Command TDIGEST_QUANTILE = new CommandImpl("tdigest.quantile", -1, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
+ Command TDIGEST_RANK = new CommandImpl("tdigest.rank", -1, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
+ Command TDIGEST_RESET = new CommandImpl("tdigest.reset", -1, false, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
+ Command TDIGEST_REVRANK = new CommandImpl("tdigest.revrank", -1, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
+ Command TDIGEST_TRIMMED_MEAN = new CommandImpl("tdigest.trimmed_mean", -1, true, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
Command TIME = new CommandImpl("time", 1, null, false, false);
Command TIMESERIES_CLUSTERSET = new CommandImpl("timeseries.CLUSTERSET", -1, true, false, false);
Command TIMESERIES_CLUSTERSETFROMSHARD = new CommandImpl("timeseries.CLUSTERSETFROMSHARD", -1, true, false, false);
@@ -355,7 +370,7 @@ public interface Command {
Command UNSUBSCRIBE = new CommandImpl("unsubscribe", -1, null, true, false);
Command UNWATCH = new CommandImpl("unwatch", 1, null, false, false);
Command WAIT = new CommandImpl("wait", 3, null, false, false);
- Command WATCH = new CommandImpl("watch", -2, null, false, false, new KeyLocator(null, new BeginSearchIndex(1), new FindKeysRange(-1, 1, 0)));
+ Command WATCH = new CommandImpl("watch", -2, null, false, false, new KeyLocator(true, new BeginSearchIndex(1), new FindKeysRange(-1, 1, 0)));
Command XACK = new CommandImpl("xack", -4, false, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
Command XADD = new CommandImpl("xadd", -5, false, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
Command XAUTOCLAIM = new CommandImpl("xautoclaim", -6, false, false, false, new KeyLocator(false, new BeginSearchIndex(1), new FindKeysRange(0, 1, 0)));
@@ -409,11 +424,15 @@ public interface Command {
/**
* Generic command generator for extensions.
+ *
+ * To avoid inconsistent behavior, when {@code command} is one of the known commands
+ * for which a static instance exists, the static instance is returned.
*
* @param command command name
* @return the cacheable immutable command instance
*/
static Command create(String command) {
- return new CommandImpl(command, -1, null, false, true);
+ Command known = CommandMap.getKnownCommand(command);
+ return known != null ? known : new CommandImpl(command, -1, null, false, true);
}
}
diff --git a/src/main/java/io/vertx/redis/client/CommandMap.java b/src/main/java/io/vertx/redis/client/CommandMap.java
new file mode 100644
index 00000000..6a1f729f
--- /dev/null
+++ b/src/main/java/io/vertx/redis/client/CommandMap.java
@@ -0,0 +1,405 @@
+package io.vertx.redis.client;
+
+import java.util.HashMap;
+import java.util.Map;
+
+class CommandMap {
+ private static final Map KNOWN_COMMANDS = new HashMap<>();
+
+ static Command getKnownCommand(String command) {
+ return command == null ? null : KNOWN_COMMANDS.get(command.toLowerCase());
+ }
+
+ // this block is auto-generated
+ static {
+ KNOWN_COMMANDS.put("acl", Command.ACL);
+ KNOWN_COMMANDS.put("append", Command.APPEND);
+ KNOWN_COMMANDS.put("asking", Command.ASKING);
+ KNOWN_COMMANDS.put("auth", Command.AUTH);
+ KNOWN_COMMANDS.put("bf.add", Command.BF_ADD);
+ KNOWN_COMMANDS.put("bf.card", Command.BF_CARD);
+ KNOWN_COMMANDS.put("bf.debug", Command.BF_DEBUG);
+ KNOWN_COMMANDS.put("bf.exists", Command.BF_EXISTS);
+ KNOWN_COMMANDS.put("bf.info", Command.BF_INFO);
+ KNOWN_COMMANDS.put("bf.insert", Command.BF_INSERT);
+ KNOWN_COMMANDS.put("bf.loadchunk", Command.BF_LOADCHUNK);
+ KNOWN_COMMANDS.put("bf.madd", Command.BF_MADD);
+ KNOWN_COMMANDS.put("bf.mexists", Command.BF_MEXISTS);
+ KNOWN_COMMANDS.put("bf.reserve", Command.BF_RESERVE);
+ KNOWN_COMMANDS.put("bf.scandump", Command.BF_SCANDUMP);
+ KNOWN_COMMANDS.put("bgrewriteaof", Command.BGREWRITEAOF);
+ KNOWN_COMMANDS.put("bgsave", Command.BGSAVE);
+ KNOWN_COMMANDS.put("bitcount", Command.BITCOUNT);
+ KNOWN_COMMANDS.put("bitfield", Command.BITFIELD);
+ KNOWN_COMMANDS.put("bitfield_ro", Command.BITFIELD_RO);
+ KNOWN_COMMANDS.put("bitop", Command.BITOP);
+ KNOWN_COMMANDS.put("bitpos", Command.BITPOS);
+ KNOWN_COMMANDS.put("blmove", Command.BLMOVE);
+ KNOWN_COMMANDS.put("blmpop", Command.BLMPOP);
+ KNOWN_COMMANDS.put("blpop", Command.BLPOP);
+ KNOWN_COMMANDS.put("brpop", Command.BRPOP);
+ KNOWN_COMMANDS.put("brpoplpush", Command.BRPOPLPUSH);
+ KNOWN_COMMANDS.put("bzmpop", Command.BZMPOP);
+ KNOWN_COMMANDS.put("bzpopmax", Command.BZPOPMAX);
+ KNOWN_COMMANDS.put("bzpopmin", Command.BZPOPMIN);
+ KNOWN_COMMANDS.put("cf.add", Command.CF_ADD);
+ KNOWN_COMMANDS.put("cf.addnx", Command.CF_ADDNX);
+ KNOWN_COMMANDS.put("cf.compact", Command.CF_COMPACT);
+ KNOWN_COMMANDS.put("cf.count", Command.CF_COUNT);
+ KNOWN_COMMANDS.put("cf.debug", Command.CF_DEBUG);
+ KNOWN_COMMANDS.put("cf.del", Command.CF_DEL);
+ KNOWN_COMMANDS.put("cf.exists", Command.CF_EXISTS);
+ KNOWN_COMMANDS.put("cf.info", Command.CF_INFO);
+ KNOWN_COMMANDS.put("cf.insert", Command.CF_INSERT);
+ KNOWN_COMMANDS.put("cf.insertnx", Command.CF_INSERTNX);
+ KNOWN_COMMANDS.put("cf.loadchunk", Command.CF_LOADCHUNK);
+ KNOWN_COMMANDS.put("cf.mexists", Command.CF_MEXISTS);
+ KNOWN_COMMANDS.put("cf.reserve", Command.CF_RESERVE);
+ KNOWN_COMMANDS.put("cf.scandump", Command.CF_SCANDUMP);
+ KNOWN_COMMANDS.put("client", Command.CLIENT);
+ KNOWN_COMMANDS.put("cluster", Command.CLUSTER);
+ KNOWN_COMMANDS.put("cms.incrby", Command.CMS_INCRBY);
+ KNOWN_COMMANDS.put("cms.info", Command.CMS_INFO);
+ KNOWN_COMMANDS.put("cms.initbydim", Command.CMS_INITBYDIM);
+ KNOWN_COMMANDS.put("cms.initbyprob", Command.CMS_INITBYPROB);
+ KNOWN_COMMANDS.put("cms.merge", Command.CMS_MERGE);
+ KNOWN_COMMANDS.put("cms.query", Command.CMS_QUERY);
+ KNOWN_COMMANDS.put("command", Command.COMMAND);
+ KNOWN_COMMANDS.put("config", Command.CONFIG);
+ KNOWN_COMMANDS.put("copy", Command.COPY);
+ KNOWN_COMMANDS.put("dbsize", Command.DBSIZE);
+ KNOWN_COMMANDS.put("debug", Command.DEBUG);
+ KNOWN_COMMANDS.put("decr", Command.DECR);
+ KNOWN_COMMANDS.put("decrby", Command.DECRBY);
+ KNOWN_COMMANDS.put("del", Command.DEL);
+ KNOWN_COMMANDS.put("discard", Command.DISCARD);
+ KNOWN_COMMANDS.put("dump", Command.DUMP);
+ KNOWN_COMMANDS.put("echo", Command.ECHO);
+ KNOWN_COMMANDS.put("eval", Command.EVAL);
+ KNOWN_COMMANDS.put("eval_ro", Command.EVAL_RO);
+ KNOWN_COMMANDS.put("evalsha", Command.EVALSHA);
+ KNOWN_COMMANDS.put("evalsha_ro", Command.EVALSHA_RO);
+ KNOWN_COMMANDS.put("exec", Command.EXEC);
+ KNOWN_COMMANDS.put("exists", Command.EXISTS);
+ KNOWN_COMMANDS.put("expire", Command.EXPIRE);
+ KNOWN_COMMANDS.put("expireat", Command.EXPIREAT);
+ KNOWN_COMMANDS.put("expiretime", Command.EXPIRETIME);
+ KNOWN_COMMANDS.put("failover", Command.FAILOVER);
+ KNOWN_COMMANDS.put("fcall", Command.FCALL);
+ KNOWN_COMMANDS.put("fcall_ro", Command.FCALL_RO);
+ KNOWN_COMMANDS.put("flushall", Command.FLUSHALL);
+ KNOWN_COMMANDS.put("flushdb", Command.FLUSHDB);
+ KNOWN_COMMANDS.put("ft._aliasaddifnx", Command.FT__ALIASADDIFNX);
+ KNOWN_COMMANDS.put("ft._aliasdelifx", Command.FT__ALIASDELIFX);
+ KNOWN_COMMANDS.put("ft._alterifnx", Command.FT__ALTERIFNX);
+ KNOWN_COMMANDS.put("ft._createifnx", Command.FT__CREATEIFNX);
+ KNOWN_COMMANDS.put("ft._dropifx", Command.FT__DROPIFX);
+ KNOWN_COMMANDS.put("ft._dropindexifx", Command.FT__DROPINDEXIFX);
+ KNOWN_COMMANDS.put("ft._list", Command.FT__LIST);
+ KNOWN_COMMANDS.put("ft.add", Command.FT_ADD);
+ KNOWN_COMMANDS.put("ft.aggregate", Command.FT_AGGREGATE);
+ KNOWN_COMMANDS.put("ft.aliasadd", Command.FT_ALIASADD);
+ KNOWN_COMMANDS.put("ft.aliasdel", Command.FT_ALIASDEL);
+ KNOWN_COMMANDS.put("ft.aliasupdate", Command.FT_ALIASUPDATE);
+ KNOWN_COMMANDS.put("ft.alter", Command.FT_ALTER);
+ KNOWN_COMMANDS.put("ft.config", Command.FT_CONFIG);
+ KNOWN_COMMANDS.put("ft.create", Command.FT_CREATE);
+ KNOWN_COMMANDS.put("ft.cursor", Command.FT_CURSOR);
+ KNOWN_COMMANDS.put("ft.debug", Command.FT_DEBUG);
+ KNOWN_COMMANDS.put("ft.del", Command.FT_DEL);
+ KNOWN_COMMANDS.put("ft.dictadd", Command.FT_DICTADD);
+ KNOWN_COMMANDS.put("ft.dictdel", Command.FT_DICTDEL);
+ KNOWN_COMMANDS.put("ft.dictdump", Command.FT_DICTDUMP);
+ KNOWN_COMMANDS.put("ft.drop", Command.FT_DROP);
+ KNOWN_COMMANDS.put("ft.dropindex", Command.FT_DROPINDEX);
+ KNOWN_COMMANDS.put("ft.explain", Command.FT_EXPLAIN);
+ KNOWN_COMMANDS.put("ft.explaincli", Command.FT_EXPLAINCLI);
+ KNOWN_COMMANDS.put("ft.get", Command.FT_GET);
+ KNOWN_COMMANDS.put("ft.info", Command.FT_INFO);
+ KNOWN_COMMANDS.put("ft.mget", Command.FT_MGET);
+ KNOWN_COMMANDS.put("ft.profile", Command.FT_PROFILE);
+ KNOWN_COMMANDS.put("ft.safeadd", Command.FT_SAFEADD);
+ KNOWN_COMMANDS.put("ft.search", Command.FT_SEARCH);
+ KNOWN_COMMANDS.put("ft.spellcheck", Command.FT_SPELLCHECK);
+ KNOWN_COMMANDS.put("ft.sugadd", Command.FT_SUGADD);
+ KNOWN_COMMANDS.put("ft.sugdel", Command.FT_SUGDEL);
+ KNOWN_COMMANDS.put("ft.sugget", Command.FT_SUGGET);
+ KNOWN_COMMANDS.put("ft.suglen", Command.FT_SUGLEN);
+ KNOWN_COMMANDS.put("ft.synadd", Command.FT_SYNADD);
+ KNOWN_COMMANDS.put("ft.syndump", Command.FT_SYNDUMP);
+ KNOWN_COMMANDS.put("ft.synupdate", Command.FT_SYNUPDATE);
+ KNOWN_COMMANDS.put("ft.tagvals", Command.FT_TAGVALS);
+ KNOWN_COMMANDS.put("function", Command.FUNCTION);
+ KNOWN_COMMANDS.put("geoadd", Command.GEOADD);
+ KNOWN_COMMANDS.put("geodist", Command.GEODIST);
+ KNOWN_COMMANDS.put("geohash", Command.GEOHASH);
+ KNOWN_COMMANDS.put("geopos", Command.GEOPOS);
+ KNOWN_COMMANDS.put("georadius", Command.GEORADIUS);
+ KNOWN_COMMANDS.put("georadius_ro", Command.GEORADIUS_RO);
+ KNOWN_COMMANDS.put("georadiusbymember", Command.GEORADIUSBYMEMBER);
+ KNOWN_COMMANDS.put("georadiusbymember_ro", Command.GEORADIUSBYMEMBER_RO);
+ KNOWN_COMMANDS.put("geosearch", Command.GEOSEARCH);
+ KNOWN_COMMANDS.put("geosearchstore", Command.GEOSEARCHSTORE);
+ KNOWN_COMMANDS.put("get", Command.GET);
+ KNOWN_COMMANDS.put("getbit", Command.GETBIT);
+ KNOWN_COMMANDS.put("getdel", Command.GETDEL);
+ KNOWN_COMMANDS.put("getex", Command.GETEX);
+ KNOWN_COMMANDS.put("getrange", Command.GETRANGE);
+ KNOWN_COMMANDS.put("getset", Command.GETSET);
+ KNOWN_COMMANDS.put("graph.bulk", Command.GRAPH_BULK);
+ KNOWN_COMMANDS.put("graph.config", Command.GRAPH_CONFIG);
+ KNOWN_COMMANDS.put("graph.debug", Command.GRAPH_DEBUG);
+ KNOWN_COMMANDS.put("graph.delete", Command.GRAPH_DELETE);
+ KNOWN_COMMANDS.put("graph.explain", Command.GRAPH_EXPLAIN);
+ KNOWN_COMMANDS.put("graph.list", Command.GRAPH_LIST);
+ KNOWN_COMMANDS.put("graph.profile", Command.GRAPH_PROFILE);
+ KNOWN_COMMANDS.put("graph.query", Command.GRAPH_QUERY);
+ KNOWN_COMMANDS.put("graph.ro_query", Command.GRAPH_RO_QUERY);
+ KNOWN_COMMANDS.put("graph.slowlog", Command.GRAPH_SLOWLOG);
+ KNOWN_COMMANDS.put("hdel", Command.HDEL);
+ KNOWN_COMMANDS.put("hello", Command.HELLO);
+ KNOWN_COMMANDS.put("hexists", Command.HEXISTS);
+ KNOWN_COMMANDS.put("hget", Command.HGET);
+ KNOWN_COMMANDS.put("hgetall", Command.HGETALL);
+ KNOWN_COMMANDS.put("hincrby", Command.HINCRBY);
+ KNOWN_COMMANDS.put("hincrbyfloat", Command.HINCRBYFLOAT);
+ KNOWN_COMMANDS.put("hkeys", Command.HKEYS);
+ KNOWN_COMMANDS.put("hlen", Command.HLEN);
+ KNOWN_COMMANDS.put("hmget", Command.HMGET);
+ KNOWN_COMMANDS.put("hmset", Command.HMSET);
+ KNOWN_COMMANDS.put("hrandfield", Command.HRANDFIELD);
+ KNOWN_COMMANDS.put("hscan", Command.HSCAN);
+ KNOWN_COMMANDS.put("hset", Command.HSET);
+ KNOWN_COMMANDS.put("hsetnx", Command.HSETNX);
+ KNOWN_COMMANDS.put("hstrlen", Command.HSTRLEN);
+ KNOWN_COMMANDS.put("hvals", Command.HVALS);
+ KNOWN_COMMANDS.put("incr", Command.INCR);
+ KNOWN_COMMANDS.put("incrby", Command.INCRBY);
+ KNOWN_COMMANDS.put("incrbyfloat", Command.INCRBYFLOAT);
+ KNOWN_COMMANDS.put("info", Command.INFO);
+ KNOWN_COMMANDS.put("json.arrappend", Command.JSON_ARRAPPEND);
+ KNOWN_COMMANDS.put("json.arrindex", Command.JSON_ARRINDEX);
+ KNOWN_COMMANDS.put("json.arrinsert", Command.JSON_ARRINSERT);
+ KNOWN_COMMANDS.put("json.arrlen", Command.JSON_ARRLEN);
+ KNOWN_COMMANDS.put("json.arrpop", Command.JSON_ARRPOP);
+ KNOWN_COMMANDS.put("json.arrtrim", Command.JSON_ARRTRIM);
+ KNOWN_COMMANDS.put("json.clear", Command.JSON_CLEAR);
+ KNOWN_COMMANDS.put("json.debug", Command.JSON_DEBUG);
+ KNOWN_COMMANDS.put("json.del", Command.JSON_DEL);
+ KNOWN_COMMANDS.put("json.forget", Command.JSON_FORGET);
+ KNOWN_COMMANDS.put("json.get", Command.JSON_GET);
+ KNOWN_COMMANDS.put("json.mget", Command.JSON_MGET);
+ KNOWN_COMMANDS.put("json.numincrby", Command.JSON_NUMINCRBY);
+ KNOWN_COMMANDS.put("json.nummultby", Command.JSON_NUMMULTBY);
+ KNOWN_COMMANDS.put("json.numpowby", Command.JSON_NUMPOWBY);
+ KNOWN_COMMANDS.put("json.objkeys", Command.JSON_OBJKEYS);
+ KNOWN_COMMANDS.put("json.objlen", Command.JSON_OBJLEN);
+ KNOWN_COMMANDS.put("json.resp", Command.JSON_RESP);
+ KNOWN_COMMANDS.put("json.set", Command.JSON_SET);
+ KNOWN_COMMANDS.put("json.strappend", Command.JSON_STRAPPEND);
+ KNOWN_COMMANDS.put("json.strlen", Command.JSON_STRLEN);
+ KNOWN_COMMANDS.put("json.toggle", Command.JSON_TOGGLE);
+ KNOWN_COMMANDS.put("json.type", Command.JSON_TYPE);
+ KNOWN_COMMANDS.put("keys", Command.KEYS);
+ KNOWN_COMMANDS.put("lastsave", Command.LASTSAVE);
+ KNOWN_COMMANDS.put("latency", Command.LATENCY);
+ KNOWN_COMMANDS.put("lcs", Command.LCS);
+ KNOWN_COMMANDS.put("lindex", Command.LINDEX);
+ KNOWN_COMMANDS.put("linsert", Command.LINSERT);
+ KNOWN_COMMANDS.put("llen", Command.LLEN);
+ KNOWN_COMMANDS.put("lmove", Command.LMOVE);
+ KNOWN_COMMANDS.put("lmpop", Command.LMPOP);
+ KNOWN_COMMANDS.put("lolwut", Command.LOLWUT);
+ KNOWN_COMMANDS.put("lpop", Command.LPOP);
+ KNOWN_COMMANDS.put("lpos", Command.LPOS);
+ KNOWN_COMMANDS.put("lpush", Command.LPUSH);
+ KNOWN_COMMANDS.put("lpushx", Command.LPUSHX);
+ KNOWN_COMMANDS.put("lrange", Command.LRANGE);
+ KNOWN_COMMANDS.put("lrem", Command.LREM);
+ KNOWN_COMMANDS.put("lset", Command.LSET);
+ KNOWN_COMMANDS.put("ltrim", Command.LTRIM);
+ KNOWN_COMMANDS.put("memory", Command.MEMORY);
+ KNOWN_COMMANDS.put("mget", Command.MGET);
+ KNOWN_COMMANDS.put("migrate", Command.MIGRATE);
+ KNOWN_COMMANDS.put("module", Command.MODULE);
+ KNOWN_COMMANDS.put("monitor", Command.MONITOR);
+ KNOWN_COMMANDS.put("move", Command.MOVE);
+ KNOWN_COMMANDS.put("mset", Command.MSET);
+ KNOWN_COMMANDS.put("msetnx", Command.MSETNX);
+ KNOWN_COMMANDS.put("multi", Command.MULTI);
+ KNOWN_COMMANDS.put("object", Command.OBJECT);
+ KNOWN_COMMANDS.put("persist", Command.PERSIST);
+ KNOWN_COMMANDS.put("pexpire", Command.PEXPIRE);
+ KNOWN_COMMANDS.put("pexpireat", Command.PEXPIREAT);
+ KNOWN_COMMANDS.put("pexpiretime", Command.PEXPIRETIME);
+ KNOWN_COMMANDS.put("pfadd", Command.PFADD);
+ KNOWN_COMMANDS.put("pfcount", Command.PFCOUNT);
+ KNOWN_COMMANDS.put("pfdebug", Command.PFDEBUG);
+ KNOWN_COMMANDS.put("pfmerge", Command.PFMERGE);
+ KNOWN_COMMANDS.put("pfselftest", Command.PFSELFTEST);
+ KNOWN_COMMANDS.put("ping", Command.PING);
+ KNOWN_COMMANDS.put("psetex", Command.PSETEX);
+ KNOWN_COMMANDS.put("psubscribe", Command.PSUBSCRIBE);
+ KNOWN_COMMANDS.put("psync", Command.PSYNC);
+ KNOWN_COMMANDS.put("pttl", Command.PTTL);
+ KNOWN_COMMANDS.put("publish", Command.PUBLISH);
+ KNOWN_COMMANDS.put("pubsub", Command.PUBSUB);
+ KNOWN_COMMANDS.put("punsubscribe", Command.PUNSUBSCRIBE);
+ KNOWN_COMMANDS.put("quit", Command.QUIT);
+ KNOWN_COMMANDS.put("randomkey", Command.RANDOMKEY);
+ KNOWN_COMMANDS.put("readonly", Command.READONLY);
+ KNOWN_COMMANDS.put("readwrite", Command.READWRITE);
+ KNOWN_COMMANDS.put("rename", Command.RENAME);
+ KNOWN_COMMANDS.put("renamenx", Command.RENAMENX);
+ KNOWN_COMMANDS.put("replconf", Command.REPLCONF);
+ KNOWN_COMMANDS.put("replicaof", Command.REPLICAOF);
+ KNOWN_COMMANDS.put("reset", Command.RESET);
+ KNOWN_COMMANDS.put("restore", Command.RESTORE);
+ KNOWN_COMMANDS.put("restore-asking", Command.RESTORE_ASKING);
+ KNOWN_COMMANDS.put("role", Command.ROLE);
+ KNOWN_COMMANDS.put("rpop", Command.RPOP);
+ KNOWN_COMMANDS.put("rpoplpush", Command.RPOPLPUSH);
+ KNOWN_COMMANDS.put("rpush", Command.RPUSH);
+ KNOWN_COMMANDS.put("rpushx", Command.RPUSHX);
+ KNOWN_COMMANDS.put("sadd", Command.SADD);
+ KNOWN_COMMANDS.put("save", Command.SAVE);
+ KNOWN_COMMANDS.put("scan", Command.SCAN);
+ KNOWN_COMMANDS.put("scard", Command.SCARD);
+ KNOWN_COMMANDS.put("script", Command.SCRIPT);
+ KNOWN_COMMANDS.put("sdiff", Command.SDIFF);
+ KNOWN_COMMANDS.put("sdiffstore", Command.SDIFFSTORE);
+ KNOWN_COMMANDS.put("select", Command.SELECT);
+ KNOWN_COMMANDS.put("set", Command.SET);
+ KNOWN_COMMANDS.put("setbit", Command.SETBIT);
+ KNOWN_COMMANDS.put("setex", Command.SETEX);
+ KNOWN_COMMANDS.put("setnx", Command.SETNX);
+ KNOWN_COMMANDS.put("setrange", Command.SETRANGE);
+ KNOWN_COMMANDS.put("shutdown", Command.SHUTDOWN);
+ KNOWN_COMMANDS.put("sinter", Command.SINTER);
+ KNOWN_COMMANDS.put("sintercard", Command.SINTERCARD);
+ KNOWN_COMMANDS.put("sinterstore", Command.SINTERSTORE);
+ KNOWN_COMMANDS.put("sismember", Command.SISMEMBER);
+ KNOWN_COMMANDS.put("slaveof", Command.SLAVEOF);
+ KNOWN_COMMANDS.put("slowlog", Command.SLOWLOG);
+ KNOWN_COMMANDS.put("smembers", Command.SMEMBERS);
+ KNOWN_COMMANDS.put("smismember", Command.SMISMEMBER);
+ KNOWN_COMMANDS.put("smove", Command.SMOVE);
+ KNOWN_COMMANDS.put("sort", Command.SORT);
+ KNOWN_COMMANDS.put("sort_ro", Command.SORT_RO);
+ KNOWN_COMMANDS.put("spop", Command.SPOP);
+ KNOWN_COMMANDS.put("spublish", Command.SPUBLISH);
+ KNOWN_COMMANDS.put("srandmember", Command.SRANDMEMBER);
+ KNOWN_COMMANDS.put("srem", Command.SREM);
+ KNOWN_COMMANDS.put("sscan", Command.SSCAN);
+ KNOWN_COMMANDS.put("ssubscribe", Command.SSUBSCRIBE);
+ KNOWN_COMMANDS.put("strlen", Command.STRLEN);
+ KNOWN_COMMANDS.put("subscribe", Command.SUBSCRIBE);
+ KNOWN_COMMANDS.put("substr", Command.SUBSTR);
+ KNOWN_COMMANDS.put("sunion", Command.SUNION);
+ KNOWN_COMMANDS.put("sunionstore", Command.SUNIONSTORE);
+ KNOWN_COMMANDS.put("sunsubscribe", Command.SUNSUBSCRIBE);
+ KNOWN_COMMANDS.put("swapdb", Command.SWAPDB);
+ KNOWN_COMMANDS.put("sync", Command.SYNC);
+ KNOWN_COMMANDS.put("tdigest.add", Command.TDIGEST_ADD);
+ KNOWN_COMMANDS.put("tdigest.byrank", Command.TDIGEST_BYRANK);
+ KNOWN_COMMANDS.put("tdigest.byrevrank", Command.TDIGEST_BYREVRANK);
+ KNOWN_COMMANDS.put("tdigest.cdf", Command.TDIGEST_CDF);
+ KNOWN_COMMANDS.put("tdigest.create", Command.TDIGEST_CREATE);
+ KNOWN_COMMANDS.put("tdigest.info", Command.TDIGEST_INFO);
+ KNOWN_COMMANDS.put("tdigest.max", Command.TDIGEST_MAX);
+ KNOWN_COMMANDS.put("tdigest.merge", Command.TDIGEST_MERGE);
+ KNOWN_COMMANDS.put("tdigest.min", Command.TDIGEST_MIN);
+ KNOWN_COMMANDS.put("tdigest.quantile", Command.TDIGEST_QUANTILE);
+ KNOWN_COMMANDS.put("tdigest.rank", Command.TDIGEST_RANK);
+ KNOWN_COMMANDS.put("tdigest.reset", Command.TDIGEST_RESET);
+ KNOWN_COMMANDS.put("tdigest.revrank", Command.TDIGEST_REVRANK);
+ KNOWN_COMMANDS.put("tdigest.trimmed_mean", Command.TDIGEST_TRIMMED_MEAN);
+ KNOWN_COMMANDS.put("time", Command.TIME);
+ KNOWN_COMMANDS.put("timeseries.clusterset", Command.TIMESERIES_CLUSTERSET);
+ KNOWN_COMMANDS.put("timeseries.clustersetfromshard", Command.TIMESERIES_CLUSTERSETFROMSHARD);
+ KNOWN_COMMANDS.put("timeseries.hello", Command.TIMESERIES_HELLO);
+ KNOWN_COMMANDS.put("timeseries.infocluster", Command.TIMESERIES_INFOCLUSTER);
+ KNOWN_COMMANDS.put("timeseries.innercommunication", Command.TIMESERIES_INNERCOMMUNICATION);
+ KNOWN_COMMANDS.put("timeseries.networktest", Command.TIMESERIES_NETWORKTEST);
+ KNOWN_COMMANDS.put("timeseries.refreshcluster", Command.TIMESERIES_REFRESHCLUSTER);
+ KNOWN_COMMANDS.put("topk.add", Command.TOPK_ADD);
+ KNOWN_COMMANDS.put("topk.count", Command.TOPK_COUNT);
+ KNOWN_COMMANDS.put("topk.incrby", Command.TOPK_INCRBY);
+ KNOWN_COMMANDS.put("topk.info", Command.TOPK_INFO);
+ KNOWN_COMMANDS.put("topk.list", Command.TOPK_LIST);
+ KNOWN_COMMANDS.put("topk.query", Command.TOPK_QUERY);
+ KNOWN_COMMANDS.put("topk.reserve", Command.TOPK_RESERVE);
+ KNOWN_COMMANDS.put("touch", Command.TOUCH);
+ KNOWN_COMMANDS.put("ts.add", Command.TS_ADD);
+ KNOWN_COMMANDS.put("ts.alter", Command.TS_ALTER);
+ KNOWN_COMMANDS.put("ts.create", Command.TS_CREATE);
+ KNOWN_COMMANDS.put("ts.createrule", Command.TS_CREATERULE);
+ KNOWN_COMMANDS.put("ts.decrby", Command.TS_DECRBY);
+ KNOWN_COMMANDS.put("ts.del", Command.TS_DEL);
+ KNOWN_COMMANDS.put("ts.deleterule", Command.TS_DELETERULE);
+ KNOWN_COMMANDS.put("ts.get", Command.TS_GET);
+ KNOWN_COMMANDS.put("ts.incrby", Command.TS_INCRBY);
+ KNOWN_COMMANDS.put("ts.info", Command.TS_INFO);
+ KNOWN_COMMANDS.put("ts.madd", Command.TS_MADD);
+ KNOWN_COMMANDS.put("ts.mget", Command.TS_MGET);
+ KNOWN_COMMANDS.put("ts.mrange", Command.TS_MRANGE);
+ KNOWN_COMMANDS.put("ts.mrevrange", Command.TS_MREVRANGE);
+ KNOWN_COMMANDS.put("ts.queryindex", Command.TS_QUERYINDEX);
+ KNOWN_COMMANDS.put("ts.range", Command.TS_RANGE);
+ KNOWN_COMMANDS.put("ts.revrange", Command.TS_REVRANGE);
+ KNOWN_COMMANDS.put("ttl", Command.TTL);
+ KNOWN_COMMANDS.put("type", Command.TYPE);
+ KNOWN_COMMANDS.put("unlink", Command.UNLINK);
+ KNOWN_COMMANDS.put("unsubscribe", Command.UNSUBSCRIBE);
+ KNOWN_COMMANDS.put("unwatch", Command.UNWATCH);
+ KNOWN_COMMANDS.put("wait", Command.WAIT);
+ KNOWN_COMMANDS.put("watch", Command.WATCH);
+ KNOWN_COMMANDS.put("xack", Command.XACK);
+ KNOWN_COMMANDS.put("xadd", Command.XADD);
+ KNOWN_COMMANDS.put("xautoclaim", Command.XAUTOCLAIM);
+ KNOWN_COMMANDS.put("xclaim", Command.XCLAIM);
+ KNOWN_COMMANDS.put("xdel", Command.XDEL);
+ KNOWN_COMMANDS.put("xgroup", Command.XGROUP);
+ KNOWN_COMMANDS.put("xinfo", Command.XINFO);
+ KNOWN_COMMANDS.put("xlen", Command.XLEN);
+ KNOWN_COMMANDS.put("xpending", Command.XPENDING);
+ KNOWN_COMMANDS.put("xrange", Command.XRANGE);
+ KNOWN_COMMANDS.put("xread", Command.XREAD);
+ KNOWN_COMMANDS.put("xreadgroup", Command.XREADGROUP);
+ KNOWN_COMMANDS.put("xrevrange", Command.XREVRANGE);
+ KNOWN_COMMANDS.put("xsetid", Command.XSETID);
+ KNOWN_COMMANDS.put("xtrim", Command.XTRIM);
+ KNOWN_COMMANDS.put("zadd", Command.ZADD);
+ KNOWN_COMMANDS.put("zcard", Command.ZCARD);
+ KNOWN_COMMANDS.put("zcount", Command.ZCOUNT);
+ KNOWN_COMMANDS.put("zdiff", Command.ZDIFF);
+ KNOWN_COMMANDS.put("zdiffstore", Command.ZDIFFSTORE);
+ KNOWN_COMMANDS.put("zincrby", Command.ZINCRBY);
+ KNOWN_COMMANDS.put("zinter", Command.ZINTER);
+ KNOWN_COMMANDS.put("zintercard", Command.ZINTERCARD);
+ KNOWN_COMMANDS.put("zinterstore", Command.ZINTERSTORE);
+ KNOWN_COMMANDS.put("zlexcount", Command.ZLEXCOUNT);
+ KNOWN_COMMANDS.put("zmpop", Command.ZMPOP);
+ KNOWN_COMMANDS.put("zmscore", Command.ZMSCORE);
+ KNOWN_COMMANDS.put("zpopmax", Command.ZPOPMAX);
+ KNOWN_COMMANDS.put("zpopmin", Command.ZPOPMIN);
+ KNOWN_COMMANDS.put("zrandmember", Command.ZRANDMEMBER);
+ KNOWN_COMMANDS.put("zrange", Command.ZRANGE);
+ KNOWN_COMMANDS.put("zrangebylex", Command.ZRANGEBYLEX);
+ KNOWN_COMMANDS.put("zrangebyscore", Command.ZRANGEBYSCORE);
+ KNOWN_COMMANDS.put("zrangestore", Command.ZRANGESTORE);
+ KNOWN_COMMANDS.put("zrank", Command.ZRANK);
+ KNOWN_COMMANDS.put("zrem", Command.ZREM);
+ KNOWN_COMMANDS.put("zremrangebylex", Command.ZREMRANGEBYLEX);
+ KNOWN_COMMANDS.put("zremrangebyrank", Command.ZREMRANGEBYRANK);
+ KNOWN_COMMANDS.put("zremrangebyscore", Command.ZREMRANGEBYSCORE);
+ KNOWN_COMMANDS.put("zrevrange", Command.ZREVRANGE);
+ KNOWN_COMMANDS.put("zrevrangebylex", Command.ZREVRANGEBYLEX);
+ KNOWN_COMMANDS.put("zrevrangebyscore", Command.ZREVRANGEBYSCORE);
+ KNOWN_COMMANDS.put("zrevrank", Command.ZREVRANK);
+ KNOWN_COMMANDS.put("zscan", Command.ZSCAN);
+ KNOWN_COMMANDS.put("zscore", Command.ZSCORE);
+ KNOWN_COMMANDS.put("zunion", Command.ZUNION);
+ KNOWN_COMMANDS.put("zunionstore", Command.ZUNIONSTORE);
+ }
+}
diff --git a/src/test/java/io/vertx/redis/client/CommandGenerator.java b/src/test/java/io/vertx/redis/client/CommandGenerator.java
index d5b864af..a0b2fc7c 100644
--- a/src/test/java/io/vertx/redis/client/CommandGenerator.java
+++ b/src/test/java/io/vertx/redis/client/CommandGenerator.java
@@ -26,8 +26,11 @@ public void start() {
.onSuccess(res -> {
List commands = new ArrayList<>();
+ List commandsMap = new ArrayList<>();
res.forEach(cmd -> {
+ String commandName = cmd.get(0).toString();
+
Boolean ro = null;
boolean getkeys = false;
@@ -111,7 +114,7 @@ public void start() {
for (Response flag : cmd.get(2)) {
if ("pubsub".equals(flag.toString())) {
// we exclude PUBSUB / PUBLISH from the flag
- if ("pubsub".equalsIgnoreCase(cmd.get(0).toString()) || "publish".equalsIgnoreCase(cmd.get(0).toString())) {
+ if ("pubsub".equalsIgnoreCase(commandName) || "publish".equalsIgnoreCase(commandName)) {
continue;
}
pubSub = true;
@@ -121,25 +124,45 @@ public void start() {
commands.add(
generateCommand(
- cmd.get(0).toString(),
+ commandName,
cmd.get(1).toInteger(),
ro,
pubSub,
getkeys,
keyLocator
));
+
+ commandsMap.add(generateCommandMap(commandName));
});
commands.sort(Comparator.naturalOrder());
for (String cmd : commands) {
System.out.println(cmd);
}
+
+ System.out.println();
+ System.out.println("----------------------------------------------------------------");
+ System.out.println();
+
+ commandsMap.sort(Comparator.naturalOrder());
+ for (String cmd : commandsMap) {
+ System.out.println(cmd);
+ }
+
vertx.close();
});
}
private String generateCommand(String name, int arity, Boolean ro, boolean pubSub, boolean getKeys, String keyLocator) {
return
- "Command " + name.replace('.', '_').replace('-', '_').toUpperCase() + " = new CommandImpl(\"" + name + "\", " + arity + ", " + ro + ", " + pubSub + ", " + getKeys + (keyLocator == null ? "" : ", " + keyLocator) + ");";
+ "Command " + toIdentifier(name) + " = new CommandImpl(\"" + name + "\", " + arity + ", " + ro + ", " + pubSub + ", " + getKeys + (keyLocator == null ? "" : ", " + keyLocator) + ");";
+ }
+
+ private String generateCommandMap(String name) {
+ return "KNOWN_COMMANDS.put(\"" + name.toLowerCase() + "\", Command." + toIdentifier(name) + ");";
+ }
+
+ private String toIdentifier(String name) {
+ return name.replace('.', '_').replace('-', '_').toUpperCase();
}
}
diff --git a/src/test/java/io/vertx/redis/client/impl/CommandNormalizationTest.java b/src/test/java/io/vertx/redis/client/impl/CommandNormalizationTest.java
new file mode 100644
index 00000000..ff5b9665
--- /dev/null
+++ b/src/test/java/io/vertx/redis/client/impl/CommandNormalizationTest.java
@@ -0,0 +1,25 @@
+package io.vertx.redis.client.impl;
+
+import io.vertx.redis.client.Command;
+import io.vertx.redis.client.Request;
+import org.junit.Test;
+
+import java.nio.charset.StandardCharsets;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+
+public class CommandNormalizationTest {
+ @Test
+ public void test() {
+ RequestImpl req = (RequestImpl) Request.cmd(Command.create("hset")).arg("key").arg("field").arg("value");
+ CommandImpl cmd = (CommandImpl) req.command();
+ assertEquals("hset", cmd.toString());
+ assertNotEquals(-1, cmd.getArity());
+ assertFalse(cmd.isReadOnly(req.getArgs()));
+ assertFalse(cmd.needsGetKeys());
+ assertEquals(1, req.keys().size());
+ assertEquals("key", new String(req.keys().get(0), StandardCharsets.UTF_8));
+ }
+}