hirlite 0.0.2 → 0.0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/hirlite_ext/extconf.rb +2 -2
- data/lib/hirlite/version.rb +1 -1
- data/vendor/rlite/deps/lua/Makefile +128 -0
- data/vendor/rlite/deps/lua/src/fpconv.c +205 -0
- data/vendor/rlite/deps/lua/src/fpconv.h +22 -0
- data/vendor/rlite/deps/lua/src/lapi.c +1087 -0
- data/vendor/rlite/deps/lua/src/lapi.h +16 -0
- data/vendor/rlite/deps/lua/src/lauxlib.c +652 -0
- data/vendor/rlite/deps/lua/src/lauxlib.h +174 -0
- data/vendor/rlite/deps/lua/src/lbaselib.c +653 -0
- data/vendor/rlite/deps/lua/src/lcode.c +831 -0
- data/vendor/rlite/deps/lua/src/lcode.h +76 -0
- data/vendor/rlite/deps/lua/src/ldblib.c +398 -0
- data/vendor/rlite/deps/lua/src/ldebug.c +638 -0
- data/vendor/rlite/deps/lua/src/ldebug.h +33 -0
- data/vendor/rlite/deps/lua/src/ldo.c +519 -0
- data/vendor/rlite/deps/lua/src/ldo.h +57 -0
- data/vendor/rlite/deps/lua/src/ldump.c +164 -0
- data/vendor/rlite/deps/lua/src/lfunc.c +174 -0
- data/vendor/rlite/deps/lua/src/lfunc.h +34 -0
- data/vendor/rlite/deps/lua/src/lgc.c +710 -0
- data/vendor/rlite/deps/lua/src/lgc.h +110 -0
- data/vendor/rlite/deps/lua/src/linit.c +38 -0
- data/vendor/rlite/deps/lua/src/liolib.c +556 -0
- data/vendor/rlite/deps/lua/src/llex.c +463 -0
- data/vendor/rlite/deps/lua/src/llex.h +81 -0
- data/vendor/rlite/deps/lua/src/llimits.h +128 -0
- data/vendor/rlite/deps/lua/src/lmathlib.c +263 -0
- data/vendor/rlite/deps/lua/src/lmem.c +86 -0
- data/vendor/rlite/deps/lua/src/lmem.h +49 -0
- data/vendor/rlite/deps/lua/src/loadlib.c +666 -0
- data/vendor/rlite/deps/lua/src/lobject.c +214 -0
- data/vendor/rlite/deps/lua/src/lobject.h +381 -0
- data/vendor/rlite/deps/lua/src/lopcodes.c +102 -0
- data/vendor/rlite/deps/lua/src/lopcodes.h +268 -0
- data/vendor/rlite/deps/lua/src/loslib.c +243 -0
- data/vendor/rlite/deps/lua/src/lparser.c +1339 -0
- data/vendor/rlite/deps/lua/src/lparser.h +82 -0
- data/vendor/rlite/deps/lua/src/lstate.c +214 -0
- data/vendor/rlite/deps/lua/src/lstate.h +169 -0
- data/vendor/rlite/deps/lua/src/lstring.c +111 -0
- data/vendor/rlite/deps/lua/src/lstring.h +31 -0
- data/vendor/rlite/deps/lua/src/lstrlib.c +871 -0
- data/vendor/rlite/deps/lua/src/ltable.c +588 -0
- data/vendor/rlite/deps/lua/src/ltable.h +40 -0
- data/vendor/rlite/deps/lua/src/ltablib.c +287 -0
- data/vendor/rlite/deps/lua/src/ltm.c +75 -0
- data/vendor/rlite/deps/lua/src/ltm.h +54 -0
- data/vendor/rlite/deps/lua/src/lua.c +392 -0
- data/vendor/rlite/deps/lua/src/lua.h +388 -0
- data/vendor/rlite/deps/lua/src/lua_bit.c +189 -0
- data/vendor/rlite/deps/lua/src/lua_cjson.c +1427 -0
- data/vendor/rlite/deps/lua/src/lua_cmsgpack.c +957 -0
- data/vendor/rlite/deps/lua/src/lua_struct.c +421 -0
- data/vendor/rlite/deps/lua/src/luac.c +200 -0
- data/vendor/rlite/deps/lua/src/luaconf.h +763 -0
- data/vendor/rlite/deps/lua/src/lualib.h +53 -0
- data/vendor/rlite/deps/lua/src/lundump.c +227 -0
- data/vendor/rlite/deps/lua/src/lundump.h +36 -0
- data/vendor/rlite/deps/lua/src/lvm.c +767 -0
- data/vendor/rlite/deps/lua/src/lvm.h +36 -0
- data/vendor/rlite/deps/lua/src/lzio.c +82 -0
- data/vendor/rlite/deps/lua/src/lzio.h +67 -0
- data/vendor/rlite/deps/lua/src/print.c +227 -0
- data/vendor/rlite/deps/lua/src/strbuf.c +251 -0
- data/vendor/rlite/deps/lua/src/strbuf.h +154 -0
- data/vendor/rlite/src/Makefile +97 -25
- data/vendor/rlite/{deps → src}/crc64.c +0 -0
- data/vendor/rlite/{deps → src}/crc64.h +0 -0
- data/vendor/rlite/src/dump.c +2 -2
- data/vendor/rlite/{deps → src}/endianconv.h +0 -0
- data/vendor/rlite/src/hirlite.c +134 -90
- data/vendor/rlite/src/hirlite.h +34 -1
- data/vendor/rlite/{deps → src}/hyperloglog.c +0 -0
- data/vendor/rlite/{deps → src}/hyperloglog.h +0 -0
- data/vendor/rlite/{deps → src}/lzf.h +0 -0
- data/vendor/rlite/{deps → src}/lzfP.h +0 -0
- data/vendor/rlite/{deps → src}/lzf_c.c +0 -0
- data/vendor/rlite/{deps → src}/lzf_d.c +0 -0
- data/vendor/rlite/src/page_btree.c +10 -10
- data/vendor/rlite/src/page_btree.h +2 -2
- data/vendor/rlite/src/page_list.c +3 -3
- data/vendor/rlite/src/page_list.h +1 -1
- data/vendor/rlite/src/page_multi_string.c +1 -1
- data/vendor/rlite/src/page_skiplist.c +1 -1
- data/vendor/rlite/src/page_skiplist.h +1 -1
- data/vendor/rlite/src/rand.c +93 -0
- data/vendor/rlite/src/rand.h +38 -0
- data/vendor/rlite/src/restore.c +286 -155
- data/vendor/rlite/src/restore.h +6 -0
- data/vendor/rlite/src/rlite.c +30 -30
- data/vendor/rlite/src/rlite.h +1 -1
- data/vendor/rlite/src/scripting.c +1138 -0
- data/vendor/rlite/src/scripting.h +10 -0
- data/vendor/rlite/{deps → src}/sha1.c +0 -0
- data/vendor/rlite/{deps → src}/sha1.h +0 -0
- data/vendor/rlite/src/solarisfixes.h +54 -0
- data/vendor/rlite/src/sort.c +4 -2
- data/vendor/rlite/src/sort.h +1 -1
- data/vendor/rlite/src/type_string.c +1 -1
- data/vendor/rlite/src/util.c +4 -4
- data/vendor/rlite/src/util.h +3 -3
- data/vendor/rlite/{deps → src}/utilfromredis.c +0 -0
- data/vendor/rlite/{deps → src}/utilfromredis.h +0 -0
- metadata +84 -15
data/vendor/rlite/src/hirlite.c
CHANGED
@@ -11,8 +11,9 @@
|
|
11
11
|
#include <time.h>
|
12
12
|
#include <unistd.h>
|
13
13
|
|
14
|
-
#include "
|
14
|
+
#include "hyperloglog.h"
|
15
15
|
#include "hirlite.h"
|
16
|
+
#include "scripting.h"
|
16
17
|
#include "util.h"
|
17
18
|
|
18
19
|
#define UNSIGN(val) ((unsigned char *)val)
|
@@ -29,9 +30,11 @@
|
|
29
30
|
if (retval == RL_NAN) {\
|
30
31
|
c->reply = createErrorObject("ERR resulting score is not a number (NaN)");\
|
31
32
|
goto cleanup;\
|
32
|
-
}
|
33
|
+
}
|
33
34
|
|
34
|
-
|
35
|
+
int strerror_r(int, char *, size_t);
|
36
|
+
|
37
|
+
struct rliteCommand *rliteLookupCommand(const char *name, size_t UNUSED(len));
|
35
38
|
static void __rliteSetError(rliteContext *c, int type, const char *str);
|
36
39
|
|
37
40
|
static int catvprintf(char** s, size_t *slen, const char *fmt, va_list ap) {
|
@@ -72,7 +75,25 @@ static rliteReply *createReplyObject(int type) {
|
|
72
75
|
return r;
|
73
76
|
}
|
74
77
|
|
75
|
-
|
78
|
+
rliteReply *createArrayObject(size_t size) {
|
79
|
+
rliteReply* reply = createReplyObject(RLITE_REPLY_ARRAY);
|
80
|
+
if (!reply) {
|
81
|
+
return NULL;
|
82
|
+
}
|
83
|
+
reply->elements = size;
|
84
|
+
reply->element = malloc(sizeof(rliteReply*) * size);
|
85
|
+
if (!reply->element) {
|
86
|
+
free(reply);
|
87
|
+
return NULL;
|
88
|
+
}
|
89
|
+
return reply;
|
90
|
+
}
|
91
|
+
|
92
|
+
rliteReply *createNullReplyObject() {
|
93
|
+
return createReplyObject(RLITE_REPLY_NIL);
|
94
|
+
}
|
95
|
+
|
96
|
+
rliteReply *createStringTypeObject(int type, const char *str, const int len) {
|
76
97
|
rliteReply *reply = createReplyObject(type);
|
77
98
|
reply->str = malloc(sizeof(char) * (len + 1));
|
78
99
|
if (!reply->str) {
|
@@ -85,23 +106,23 @@ static rliteReply *createStringTypeObject(int type, const char *str, const int l
|
|
85
106
|
return reply;
|
86
107
|
}
|
87
108
|
|
88
|
-
|
109
|
+
rliteReply *createStringObject(const char *str, const int len) {
|
89
110
|
return createStringTypeObject(RLITE_REPLY_STRING, str, len);
|
90
111
|
}
|
91
112
|
|
92
|
-
|
113
|
+
rliteReply *createCStringObject(const char *str) {
|
93
114
|
return createStringObject(str, strlen(str));
|
94
115
|
}
|
95
116
|
|
96
|
-
|
117
|
+
rliteReply *createErrorObject(const char *str) {
|
97
118
|
return createStringTypeObject(RLITE_REPLY_ERROR, str, strlen((char *)str));
|
98
119
|
}
|
99
120
|
|
100
|
-
|
121
|
+
rliteReply *createStatusObject(const char *str) {
|
101
122
|
return createStringTypeObject(RLITE_REPLY_STATUS, str, strlen((char *)str));
|
102
123
|
}
|
103
124
|
|
104
|
-
|
125
|
+
rliteReply *createDoubleObject(double d) {
|
105
126
|
char dbuf[128];
|
106
127
|
int dlen;
|
107
128
|
if (isinf(d)) {
|
@@ -114,7 +135,7 @@ static rliteReply *createDoubleObject(double d) {
|
|
114
135
|
}
|
115
136
|
}
|
116
137
|
|
117
|
-
|
138
|
+
rliteReply *createLongLongObject(long long value) {
|
118
139
|
rliteReply *reply = createReplyObject(RLITE_REPLY_INTEGER);
|
119
140
|
reply->integer = value;
|
120
141
|
return reply;
|
@@ -259,13 +280,20 @@ static int getDoubleFromObjectOrReply(rliteClient *c, const char *o, long olen,
|
|
259
280
|
return RLITE_OK;
|
260
281
|
}
|
261
282
|
|
262
|
-
static int getLongLongFromObject(const char *
|
283
|
+
static int getLongLongFromObject(const char *_o, size_t len, long long *target) {
|
263
284
|
long long value;
|
264
285
|
char *eptr;
|
265
286
|
|
266
|
-
if (
|
287
|
+
if (_o == NULL) {
|
267
288
|
value = 0;
|
268
289
|
} else {
|
290
|
+
if (len > 38) {
|
291
|
+
return RLITE_ERR;
|
292
|
+
}
|
293
|
+
char o[40];
|
294
|
+
memcpy(o, _o, len);
|
295
|
+
o[len] = 0;
|
296
|
+
|
269
297
|
errno = 0;
|
270
298
|
value = strtoll(o, &eptr, 10);
|
271
299
|
if (isspace(((char*)o)[0]) || eptr[0] != '\0' || errno == ERANGE) {
|
@@ -276,9 +304,9 @@ static int getLongLongFromObject(const char *o, long long *target) {
|
|
276
304
|
return RLITE_OK;
|
277
305
|
}
|
278
306
|
|
279
|
-
|
307
|
+
int getLongLongFromObjectOrReply(rliteClient *c, const char *o, size_t len, long long *target, const char *msg) {
|
280
308
|
long long value;
|
281
|
-
if (getLongLongFromObject(o, &value) != RLITE_OK) {
|
309
|
+
if (getLongLongFromObject(o, len, &value) != RLITE_OK) {
|
282
310
|
if (msg != NULL) {
|
283
311
|
c->reply = createErrorObject(msg);
|
284
312
|
} else {
|
@@ -290,10 +318,10 @@ static int getLongLongFromObjectOrReply(rliteClient *c, const char *o, long long
|
|
290
318
|
return RLITE_OK;
|
291
319
|
}
|
292
320
|
|
293
|
-
static int getLongFromObjectOrReply(rliteClient *c, const char *o, long *target, const char *msg) {
|
321
|
+
static int getLongFromObjectOrReply(rliteClient *c, const char *o, size_t len, long *target, const char *msg) {
|
294
322
|
long long value;
|
295
323
|
|
296
|
-
if (getLongLongFromObjectOrReply(c, o, &value, msg) != RLITE_OK) return RLITE_ERR;
|
324
|
+
if (getLongLongFromObjectOrReply(c, o, len, &value, msg) != RLITE_OK) return RLITE_ERR;
|
297
325
|
if (value < LONG_MIN || value > LONG_MAX) {
|
298
326
|
if (msg != NULL) {
|
299
327
|
c->reply = createErrorObject(msg);
|
@@ -598,6 +626,7 @@ static rliteContext *_rliteConnect(const char *path) {
|
|
598
626
|
context->hashtableLimitEntries = 0;
|
599
627
|
context->cluster_enabled = 0;
|
600
628
|
context->hashtableLimitValue = 0;
|
629
|
+
context->inLuaScript = 0;
|
601
630
|
int retval = rl_open(path, &context->db, RLITE_OPEN_READWRITE | RLITE_OPEN_CREATE);
|
602
631
|
if (retval != RL_OK) {
|
603
632
|
free(context);
|
@@ -749,7 +778,7 @@ static void execCommand(rliteClient *c) {
|
|
749
778
|
for (i = 0; i < c->reply->elements; i++) {
|
750
779
|
client = c->context->enqueuedCommands[i];
|
751
780
|
client->reply = NULL;
|
752
|
-
command =
|
781
|
+
command = rliteLookupCommand(client->argv[0], client->argvlen[0]);
|
753
782
|
|
754
783
|
if (client->context->writeCommand) {
|
755
784
|
RL_CALL(rl_dirty_hash, RL_OK, client->context->db, &oldhash);
|
@@ -884,7 +913,7 @@ static void flagTransactions(rliteClient *c) {
|
|
884
913
|
}
|
885
914
|
}
|
886
915
|
|
887
|
-
|
916
|
+
int rliteAppendCommandClient(rliteClient *client) {
|
888
917
|
if (client->argc == 0) {
|
889
918
|
return RLITE_ERR;
|
890
919
|
}
|
@@ -892,7 +921,7 @@ static int __rliteAppendCommandClient(rliteClient *client) {
|
|
892
921
|
unsigned char *oldhash = NULL, *newhash = NULL;
|
893
922
|
void *tmp;
|
894
923
|
size_t newAlloc;
|
895
|
-
struct rliteCommand *command =
|
924
|
+
struct rliteCommand *command = rliteLookupCommand(client->argv[0], client->argvlen[0]);
|
896
925
|
int i, retval = RLITE_OK;
|
897
926
|
if (!command) {
|
898
927
|
retval = addReplyErrorFormat(client->context, "unknown command '%s'", (char*)client->argv[0]);
|
@@ -919,6 +948,7 @@ static int __rliteAppendCommandClient(rliteClient *client) {
|
|
919
948
|
client->context->enqueuedCommandsAlloc = newAlloc;
|
920
949
|
}
|
921
950
|
client->context->enqueuedCommands[client->context->enqueuedCommandsLength] = malloc(sizeof(rliteClient));
|
951
|
+
client->context->enqueuedCommands[client->context->enqueuedCommandsLength]->flags = 0;
|
922
952
|
if (!client->context->enqueuedCommands[client->context->enqueuedCommandsLength]) {
|
923
953
|
retval = RL_OUT_OF_MEMORY;
|
924
954
|
__rliteSetError(client->context, RLITE_ERR_OOM, "Out of memory");
|
@@ -979,7 +1009,7 @@ int rlitevAppendCommand(rliteContext *c, const char *format, va_list ap) {
|
|
979
1009
|
return RLITE_ERR;
|
980
1010
|
}
|
981
1011
|
|
982
|
-
int retval =
|
1012
|
+
int retval = rliteAppendCommandClient(&client);
|
983
1013
|
int i;
|
984
1014
|
for (i = 0; i < client.argc; i++) {
|
985
1015
|
free(client.argv[i]);
|
@@ -1006,7 +1036,7 @@ int rliteAppendCommandArgv(rliteContext *c, int argc, char **argv, size_t *argvl
|
|
1006
1036
|
client.argv = argv;
|
1007
1037
|
client.argvlen = argvlen;
|
1008
1038
|
|
1009
|
-
return
|
1039
|
+
return rliteAppendCommandClient(&client);
|
1010
1040
|
}
|
1011
1041
|
|
1012
1042
|
void *rlitevCommand(rliteContext *c, const char *format, va_list ap) {
|
@@ -1104,8 +1134,8 @@ static void zrangeGenericCommand(rliteClient *c, int reverse) {
|
|
1104
1134
|
long start;
|
1105
1135
|
long end;
|
1106
1136
|
|
1107
|
-
if ((getLongFromObjectOrReply(c, c->argv[2], &start, NULL) != RLITE_OK) ||
|
1108
|
-
(getLongFromObjectOrReply(c, c->argv[3], &end, NULL) != RLITE_OK)) return;
|
1137
|
+
if ((getLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &start, NULL) != RLITE_OK) ||
|
1138
|
+
(getLongFromObjectOrReply(c, c->argv[3], c->argvlen[3], &end, NULL) != RLITE_OK)) return;
|
1109
1139
|
|
1110
1140
|
if (c->argc == 5 && !strcasecmp(c->argv[4], "withscores")) {
|
1111
1141
|
withscores = 1;
|
@@ -1191,8 +1221,8 @@ static void zremrangeGenericCommand(rliteClient *c, int rangetype) {
|
|
1191
1221
|
|
1192
1222
|
/* Step 1: Parse the range. */
|
1193
1223
|
if (rangetype == ZRANGE_RANK) {
|
1194
|
-
if ((getLongFromObjectOrReply(c,c->argv[2],&start,NULL) != RLITE_OK) ||
|
1195
|
-
(getLongFromObjectOrReply(c,c->argv[3],&end,NULL) != RLITE_OK))
|
1224
|
+
if ((getLongFromObjectOrReply(c,c->argv[2],c->argvlen[2],&start,NULL) != RLITE_OK) ||
|
1225
|
+
(getLongFromObjectOrReply(c,c->argv[3],c->argvlen[3],&end,NULL) != RLITE_OK))
|
1196
1226
|
return;
|
1197
1227
|
retval = rl_zremrangebyrank(c->context->db, UNSIGN(c->argv[1]), c->argvlen[1], start, end, &deleted);
|
1198
1228
|
} else if (rangetype == ZRANGE_SCORE) {
|
@@ -1247,7 +1277,7 @@ static void zunionInterGenericCommand(rliteClient *c, int op) {
|
|
1247
1277
|
double *weights = NULL;
|
1248
1278
|
|
1249
1279
|
/* expect setnum input keys to be given */
|
1250
|
-
if ((getLongFromObjectOrReply(c, c->argv[2], &setnum, NULL) != RLITE_OK))
|
1280
|
+
if ((getLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &setnum, NULL) != RLITE_OK))
|
1251
1281
|
return;
|
1252
1282
|
|
1253
1283
|
if (setnum < 1) {
|
@@ -1357,8 +1387,8 @@ static void genericZrangebyscoreCommand(rliteClient *c, int reverse) {
|
|
1357
1387
|
pos++; remaining--;
|
1358
1388
|
withscores = 1;
|
1359
1389
|
} else if (remaining >= 3 && !strcasecmp(c->argv[pos],"limit")) {
|
1360
|
-
if ((getLongFromObjectOrReply(c, c->argv[pos+1], &offset, NULL) != RLITE_OK) ||
|
1361
|
-
(getLongFromObjectOrReply(c, c->argv[pos+2], &limit, NULL) != RLITE_OK)) return;
|
1390
|
+
if ((getLongFromObjectOrReply(c, c->argv[pos+1], c->argvlen[pos+1], &offset, NULL) != RLITE_OK) ||
|
1391
|
+
(getLongFromObjectOrReply(c, c->argv[pos+2], c->argvlen[pos+2], &limit, NULL) != RLITE_OK)) return;
|
1362
1392
|
pos += 3; remaining -= 3;
|
1363
1393
|
} else {
|
1364
1394
|
c->reply = createErrorObject(RLITE_SYNTAXERR);
|
@@ -1404,8 +1434,8 @@ static void genericZrangebylexCommand(rliteClient *c, int reverse) {
|
|
1404
1434
|
|
1405
1435
|
while (remaining) {
|
1406
1436
|
if (remaining >= 3 && !strcasecmp(c->argv[pos],"limit")) {
|
1407
|
-
if ((getLongFromObjectOrReply(c, c->argv[pos+1], &offset, NULL) != RLITE_OK) ||
|
1408
|
-
(getLongFromObjectOrReply(c, c->argv[pos+2], &limit, NULL) != RLITE_OK)) return;
|
1437
|
+
if ((getLongFromObjectOrReply(c, c->argv[pos+1], c->argvlen[pos+1], &offset, NULL) != RLITE_OK) ||
|
1438
|
+
(getLongFromObjectOrReply(c, c->argv[pos+2], c->argvlen[pos+2], &limit, NULL) != RLITE_OK)) return;
|
1409
1439
|
pos += 3; remaining -= 3;
|
1410
1440
|
} else {
|
1411
1441
|
c->reply = createErrorObject(RLITE_SYNTAXERR);
|
@@ -1617,8 +1647,8 @@ static void bitcountCommand(rliteClient *c) {
|
|
1617
1647
|
}
|
1618
1648
|
|
1619
1649
|
if (c->argc == 4) {
|
1620
|
-
if (getLongFromObjectOrReply(c, c->argv[2], &start, NULL) != RLITE_OK ||
|
1621
|
-
getLongFromObjectOrReply(c, c->argv[3], &stop, NULL) != RLITE_OK)
|
1650
|
+
if (getLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &start, NULL) != RLITE_OK ||
|
1651
|
+
getLongFromObjectOrReply(c, c->argv[3], c->argvlen[3], &stop, NULL) != RLITE_OK)
|
1622
1652
|
return;
|
1623
1653
|
}
|
1624
1654
|
|
@@ -1702,14 +1732,14 @@ static void bitposCommand(rliteClient *c) {
|
|
1702
1732
|
bit = c->argv[2][0] == '0' ? 0 : 1;
|
1703
1733
|
|
1704
1734
|
if (c->argc >= 4) {
|
1705
|
-
if (getLongFromObjectOrReply(c, c->argv[3], &start, NULL) != RLITE_OK)
|
1735
|
+
if (getLongFromObjectOrReply(c, c->argv[3], c->argvlen[3], &start, NULL) != RLITE_OK)
|
1706
1736
|
return;
|
1707
1737
|
}
|
1708
1738
|
|
1709
1739
|
int end_given = 0;
|
1710
1740
|
if (c->argc == 5) {
|
1711
1741
|
end_given = 1;
|
1712
|
-
if (getLongFromObjectOrReply(c, c->argv[4], &stop, NULL) != RLITE_OK)
|
1742
|
+
if (getLongFromObjectOrReply(c, c->argv[4], c->argvlen[4], &stop, NULL) != RLITE_OK)
|
1713
1743
|
return;
|
1714
1744
|
}
|
1715
1745
|
|
@@ -1771,7 +1801,7 @@ static void hincrbyCommand(rliteClient *c) {
|
|
1771
1801
|
int retval;
|
1772
1802
|
long increment, newvalue;
|
1773
1803
|
|
1774
|
-
if ((getLongFromObjectOrReply(c, c->argv[3], &increment, NULL) != RLITE_OK)) return;
|
1804
|
+
if ((getLongFromObjectOrReply(c, c->argv[3], c->argvlen[3], &increment, NULL) != RLITE_OK)) return;
|
1775
1805
|
|
1776
1806
|
retval = rl_hincrby(c->context->db, key, keylen, UNSIGN(c->argv[2]), c->argvlen[2], increment, &newvalue);
|
1777
1807
|
if (retval == RL_NAN) {
|
@@ -2014,7 +2044,7 @@ static void srandmemberCommand(rliteClient *c) {
|
|
2014
2044
|
count = 1;
|
2015
2045
|
repeat = 0;
|
2016
2046
|
} else {
|
2017
|
-
if ((getLongFromObjectOrReply(c, c->argv[2], &count, NULL) != RLITE_OK)) return;
|
2047
|
+
if ((getLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &count, NULL) != RLITE_OK)) return;
|
2018
2048
|
repeat = count < 0 ? 1 : 0;
|
2019
2049
|
count = count >= 0 ? count : -count;
|
2020
2050
|
}
|
@@ -2397,7 +2427,7 @@ static void lindexCommand(rliteClient *c) {
|
|
2397
2427
|
unsigned char *value;
|
2398
2428
|
long valuelen;
|
2399
2429
|
|
2400
|
-
if ((getLongFromObjectOrReply(c, c->argv[2], &index, NULL) != RLITE_OK))
|
2430
|
+
if ((getLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &index, NULL) != RLITE_OK))
|
2401
2431
|
return;
|
2402
2432
|
|
2403
2433
|
int retval = rl_lindex(c->context->db, UNSIGN(c->argv[1]), c->argvlen[1], index, &value, &valuelen);
|
@@ -2447,8 +2477,8 @@ static void lrangeCommand(rliteClient *c) {
|
|
2447
2477
|
|
2448
2478
|
long start, stop, i;
|
2449
2479
|
|
2450
|
-
if ((getLongFromObjectOrReply(c, c->argv[2], &start, NULL) != RLITE_OK) ||
|
2451
|
-
(getLongFromObjectOrReply(c, c->argv[3], &stop, NULL) != RLITE_OK)) return;
|
2480
|
+
if ((getLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &start, NULL) != RLITE_OK) ||
|
2481
|
+
(getLongFromObjectOrReply(c, c->argv[3], c->argvlen[3], &stop, NULL) != RLITE_OK)) return;
|
2452
2482
|
|
2453
2483
|
int retval = rl_lrange(c->context->db, key, keylen, start, stop, &size, &values, &valueslen);
|
2454
2484
|
RLITE_SERVER_ERR(c, retval);
|
@@ -2478,7 +2508,7 @@ static void lremCommand(rliteClient *c) {
|
|
2478
2508
|
long count, maxcount, resultcount;
|
2479
2509
|
int direction;
|
2480
2510
|
|
2481
|
-
if ((getLongFromObjectOrReply(c, c->argv[2], &count, NULL) != RLITE_OK)) return;
|
2511
|
+
if ((getLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &count, NULL) != RLITE_OK)) return;
|
2482
2512
|
|
2483
2513
|
if (count >= 0) {
|
2484
2514
|
direction = 1;
|
@@ -2499,7 +2529,7 @@ static void lsetCommand(rliteClient *c) {
|
|
2499
2529
|
size_t keylen = c->argvlen[1];
|
2500
2530
|
long index;
|
2501
2531
|
|
2502
|
-
if ((getLongFromObjectOrReply(c, c->argv[2], &index, NULL) != RLITE_OK)) return;
|
2532
|
+
if ((getLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &index, NULL) != RLITE_OK)) return;
|
2503
2533
|
|
2504
2534
|
int retval = rl_lset(c->context->db, key, keylen, index, UNSIGN(c->argv[3]), c->argvlen[3]);
|
2505
2535
|
RLITE_SERVER_ERR(c, retval);
|
@@ -2519,8 +2549,8 @@ static void ltrimCommand(rliteClient *c) {
|
|
2519
2549
|
size_t keylen = c->argvlen[1];
|
2520
2550
|
long start, stop;
|
2521
2551
|
|
2522
|
-
if ((getLongFromObjectOrReply(c, c->argv[2], &start, NULL) != RLITE_OK) ||
|
2523
|
-
(getLongFromObjectOrReply(c, c->argv[3], &stop, NULL) != RLITE_OK)) return;
|
2552
|
+
if ((getLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &start, NULL) != RLITE_OK) ||
|
2553
|
+
(getLongFromObjectOrReply(c, c->argv[3], c->argvlen[3], &stop, NULL) != RLITE_OK)) return;
|
2524
2554
|
|
2525
2555
|
int retval = rl_ltrim(c->context->db, key, keylen, start, stop);
|
2526
2556
|
RLITE_SERVER_ERR(c, retval);
|
@@ -2550,9 +2580,9 @@ cleanup:
|
|
2550
2580
|
return;
|
2551
2581
|
}
|
2552
2582
|
|
2553
|
-
#define
|
2554
|
-
#define
|
2555
|
-
#define
|
2583
|
+
#define RLITE_SET_NO_FLAGS 0
|
2584
|
+
#define RLITE_SET_NX (1<<0) /* Set if key not exists. */
|
2585
|
+
#define RLITE_SET_XX (1<<1) /* Set if key exists. */
|
2556
2586
|
|
2557
2587
|
static void setGenericCommand(rliteClient *c, int flags, const unsigned char *key, long keylen, unsigned char *value, long valuelen, long long expire) {
|
2558
2588
|
int retval;
|
@@ -2567,10 +2597,10 @@ static void setGenericCommand(rliteClient *c, int flags, const unsigned char *ke
|
|
2567
2597
|
milliseconds = rl_mstime() + expire;
|
2568
2598
|
}
|
2569
2599
|
|
2570
|
-
if ((flags &
|
2600
|
+
if ((flags & RLITE_SET_NX) || (flags & RLITE_SET_XX)) {
|
2571
2601
|
retval = rl_key_get(c->context->db, key, keylen, NULL, NULL, NULL, NULL, NULL);
|
2572
|
-
if (((flags &
|
2573
|
-
((flags &
|
2602
|
+
if (((flags & RLITE_SET_NX) && retval == RL_FOUND) ||
|
2603
|
+
((flags & RLITE_SET_XX) && retval == RL_NOT_FOUND)) {
|
2574
2604
|
c->reply = createReplyObject(RLITE_REPLY_NIL);
|
2575
2605
|
return;
|
2576
2606
|
}
|
@@ -2589,22 +2619,22 @@ static void setCommand(rliteClient *c) {
|
|
2589
2619
|
size_t keylen = c->argvlen[1];
|
2590
2620
|
int j;
|
2591
2621
|
long long expire = 0, next;
|
2592
|
-
int flags =
|
2622
|
+
int flags = RLITE_SET_NO_FLAGS;
|
2593
2623
|
|
2594
2624
|
for (j = 3; j < c->argc; j++) {
|
2595
2625
|
char *a = c->argv[j];
|
2596
2626
|
|
2597
2627
|
next = 0;
|
2598
|
-
if (j < c->argc - 1 && getLongLongFromObject(c->argv[j + 1], &next) != RLITE_OK) {
|
2628
|
+
if (j < c->argc - 1 && getLongLongFromObject(c->argv[j + 1], c->argvlen[j + 1], &next) != RLITE_OK) {
|
2599
2629
|
next = 0;
|
2600
2630
|
}
|
2601
2631
|
|
2602
2632
|
if ((a[0] == 'n' || a[0] == 'N') &&
|
2603
2633
|
(a[1] == 'x' || a[1] == 'X') && a[2] == '\0') {
|
2604
|
-
flags |=
|
2634
|
+
flags |= RLITE_SET_NX;
|
2605
2635
|
} else if ((a[0] == 'x' || a[0] == 'X') &&
|
2606
2636
|
(a[1] == 'x' || a[1] == 'X') && a[2] == '\0') {
|
2607
|
-
flags |=
|
2637
|
+
flags |= RLITE_SET_XX;
|
2608
2638
|
} else if ((a[0] == 'e' || a[0] == 'E') &&
|
2609
2639
|
(a[1] == 'x' || a[1] == 'X') && a[2] == '\0' && next) {
|
2610
2640
|
expire = next * 1000;
|
@@ -2624,7 +2654,7 @@ static void setCommand(rliteClient *c) {
|
|
2624
2654
|
|
2625
2655
|
static void setnxCommand(rliteClient *c) {
|
2626
2656
|
rliteReply *reply;
|
2627
|
-
setGenericCommand(c,
|
2657
|
+
setGenericCommand(c, RLITE_SET_NX, UNSIGN(c->argv[1]), c->argvlen[1], UNSIGN(c->argv[2]), c->argvlen[2], 0);
|
2628
2658
|
reply = c->reply;
|
2629
2659
|
if (reply->type == RLITE_REPLY_NIL) {
|
2630
2660
|
c->reply = createLongLongObject(0);
|
@@ -2636,20 +2666,20 @@ static void setnxCommand(rliteClient *c) {
|
|
2636
2666
|
|
2637
2667
|
static void setexCommand(rliteClient *c) {
|
2638
2668
|
long long expire;
|
2639
|
-
if (getLongLongFromObject(c->argv[2], &expire) != RLITE_OK) {
|
2669
|
+
if (getLongLongFromObject(c->argv[2], c->argvlen[2], &expire) != RLITE_OK) {
|
2640
2670
|
c->reply = createErrorObject(RLITE_SYNTAXERR);
|
2641
2671
|
return;
|
2642
2672
|
}
|
2643
|
-
setGenericCommand(c,
|
2673
|
+
setGenericCommand(c, RLITE_SET_NO_FLAGS, UNSIGN(c->argv[1]), c->argvlen[1], UNSIGN(c->argv[3]), c->argvlen[3], expire * 1000);
|
2644
2674
|
}
|
2645
2675
|
|
2646
2676
|
static void psetexCommand(rliteClient *c) {
|
2647
2677
|
long long expire;
|
2648
|
-
if (getLongLongFromObject(c->argv[2], &expire) != RLITE_OK) {
|
2678
|
+
if (getLongLongFromObject(c->argv[2], c->argvlen[2], &expire) != RLITE_OK) {
|
2649
2679
|
c->reply = createErrorObject(RLITE_SYNTAXERR);
|
2650
2680
|
return;
|
2651
2681
|
}
|
2652
|
-
setGenericCommand(c,
|
2682
|
+
setGenericCommand(c, RLITE_SET_NO_FLAGS, UNSIGN(c->argv[1]), c->argvlen[1], UNSIGN(c->argv[3]), c->argvlen[3], expire);
|
2653
2683
|
}
|
2654
2684
|
|
2655
2685
|
static void getCommand(rliteClient *c) {
|
@@ -2829,8 +2859,8 @@ static void getrangeCommand(rliteClient *c) {
|
|
2829
2859
|
long valuelen;
|
2830
2860
|
long long start, stop;
|
2831
2861
|
|
2832
|
-
if (getLongLongFromObject(c->argv[2], &start) != RLITE_OK ||
|
2833
|
-
getLongLongFromObject(c->argv[3], &stop) != RLITE_OK) {
|
2862
|
+
if (getLongLongFromObject(c->argv[2], c->argvlen[2], &start) != RLITE_OK ||
|
2863
|
+
getLongLongFromObject(c->argv[3], c->argvlen[3], &stop) != RLITE_OK) {
|
2834
2864
|
c->reply = createErrorObject(RLITE_SYNTAXERR);
|
2835
2865
|
return;
|
2836
2866
|
}
|
@@ -2858,7 +2888,7 @@ static void setrangeCommand(rliteClient *c) {
|
|
2858
2888
|
long newlength;
|
2859
2889
|
int retval;
|
2860
2890
|
|
2861
|
-
if (getLongLongFromObject(c->argv[2], &offset) != RLITE_OK) {
|
2891
|
+
if (getLongLongFromObject(c->argv[2], c->argvlen[2], &offset) != RLITE_OK) {
|
2862
2892
|
c->reply = createErrorObject(RLITE_SYNTAXERR);
|
2863
2893
|
return;
|
2864
2894
|
}
|
@@ -2933,7 +2963,7 @@ static void decrCommand(rliteClient *c) {
|
|
2933
2963
|
|
2934
2964
|
static void incrbyCommand(rliteClient *c) {
|
2935
2965
|
long long increment;
|
2936
|
-
if (getLongLongFromObjectOrReply(c, c->argv[2], &increment, RLITE_SYNTAXERR) != RLITE_OK) {
|
2966
|
+
if (getLongLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &increment, RLITE_SYNTAXERR) != RLITE_OK) {
|
2937
2967
|
return;
|
2938
2968
|
}
|
2939
2969
|
incrGenericCommand(c, increment);
|
@@ -2941,7 +2971,7 @@ static void incrbyCommand(rliteClient *c) {
|
|
2941
2971
|
|
2942
2972
|
static void decrbyCommand(rliteClient *c) {
|
2943
2973
|
long long decrement;
|
2944
|
-
if (getLongLongFromObjectOrReply(c, c->argv[2], &decrement, RLITE_SYNTAXERR) != RLITE_OK) {
|
2974
|
+
if (getLongLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &decrement, RLITE_SYNTAXERR) != RLITE_OK) {
|
2945
2975
|
return;
|
2946
2976
|
}
|
2947
2977
|
incrGenericCommand(c, -decrement);
|
@@ -2974,7 +3004,7 @@ static void getbitCommand(rliteClient *c) {
|
|
2974
3004
|
long long offset;
|
2975
3005
|
int value;
|
2976
3006
|
|
2977
|
-
if (getLongLongFromObjectOrReply(c, c->argv[2], &offset, RLITE_SYNTAXERR) != RLITE_OK) {
|
3007
|
+
if (getLongLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &offset, RLITE_SYNTAXERR) != RLITE_OK) {
|
2978
3008
|
return;
|
2979
3009
|
}
|
2980
3010
|
int retval = rl_getbit(c->context->db, key, keylen, offset, &value);
|
@@ -2993,7 +3023,7 @@ static void setbitCommand(rliteClient *c) {
|
|
2993
3023
|
int previousvalue;
|
2994
3024
|
int bit;
|
2995
3025
|
|
2996
|
-
if (getLongLongFromObjectOrReply(c, c->argv[2], &offset, RLITE_SYNTAXERR) != RLITE_OK) {
|
3026
|
+
if (getLongLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &offset, RLITE_SYNTAXERR) != RLITE_OK) {
|
2997
3027
|
return;
|
2998
3028
|
}
|
2999
3029
|
|
@@ -3197,7 +3227,7 @@ cleanup:
|
|
3197
3227
|
static void expireCommand(rliteClient *c) {
|
3198
3228
|
unsigned long long now = rl_mstime();
|
3199
3229
|
long long arg;
|
3200
|
-
if (getLongLongFromObjectOrReply(c, c->argv[2], &arg, RLITE_SYNTAXERR) != RLITE_OK) {
|
3230
|
+
if (getLongLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &arg, RLITE_SYNTAXERR) != RLITE_OK) {
|
3201
3231
|
return;
|
3202
3232
|
}
|
3203
3233
|
expireGenericCommand(c, now + arg * 1000);
|
@@ -3205,7 +3235,7 @@ static void expireCommand(rliteClient *c) {
|
|
3205
3235
|
|
3206
3236
|
static void expireatCommand(rliteClient *c) {
|
3207
3237
|
long long arg;
|
3208
|
-
if (getLongLongFromObjectOrReply(c, c->argv[2], &arg, RLITE_SYNTAXERR) != RLITE_OK) {
|
3238
|
+
if (getLongLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &arg, RLITE_SYNTAXERR) != RLITE_OK) {
|
3209
3239
|
return;
|
3210
3240
|
}
|
3211
3241
|
expireGenericCommand(c, arg * 1000);
|
@@ -3214,7 +3244,7 @@ static void expireatCommand(rliteClient *c) {
|
|
3214
3244
|
static void pexpireCommand(rliteClient *c) {
|
3215
3245
|
unsigned long long now = rl_mstime();
|
3216
3246
|
long long arg;
|
3217
|
-
if (getLongLongFromObjectOrReply(c, c->argv[2], &arg, RLITE_SYNTAXERR) != RLITE_OK) {
|
3247
|
+
if (getLongLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &arg, RLITE_SYNTAXERR) != RLITE_OK) {
|
3218
3248
|
return;
|
3219
3249
|
}
|
3220
3250
|
expireGenericCommand(c, now + arg);
|
@@ -3222,7 +3252,7 @@ static void pexpireCommand(rliteClient *c) {
|
|
3222
3252
|
|
3223
3253
|
static void pexpireatCommand(rliteClient *c) {
|
3224
3254
|
long long arg;
|
3225
|
-
if (getLongLongFromObjectOrReply(c, c->argv[2], &arg, RLITE_SYNTAXERR) != RLITE_OK) {
|
3255
|
+
if (getLongLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &arg, RLITE_SYNTAXERR) != RLITE_OK) {
|
3226
3256
|
return;
|
3227
3257
|
}
|
3228
3258
|
expireGenericCommand(c, arg);
|
@@ -3230,7 +3260,7 @@ static void pexpireatCommand(rliteClient *c) {
|
|
3230
3260
|
|
3231
3261
|
static void selectCommand(rliteClient *c) {
|
3232
3262
|
long long db;
|
3233
|
-
if (getLongLongFromObjectOrReply(c, c->argv[1], &db, RLITE_SYNTAXERR) != RLITE_OK) {
|
3263
|
+
if (getLongLongFromObjectOrReply(c, c->argv[1], c->argvlen[1], &db, RLITE_SYNTAXERR) != RLITE_OK) {
|
3234
3264
|
return;
|
3235
3265
|
}
|
3236
3266
|
int retval = rl_select(c->context->db, db);
|
@@ -3250,7 +3280,7 @@ static void moveCommand(rliteClient *c) {
|
|
3250
3280
|
unsigned char *key = UNSIGN(c->argv[1]);
|
3251
3281
|
long keylen = c->argvlen[1];
|
3252
3282
|
long long db;
|
3253
|
-
if (getLongLongFromObjectOrReply(c, c->argv[2], &db, "ERR index out of range") != RLITE_OK) {
|
3283
|
+
if (getLongLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &db, "ERR index out of range") != RLITE_OK) {
|
3254
3284
|
return;
|
3255
3285
|
}
|
3256
3286
|
int retval = rl_move(c->context->db, key, keylen, db);
|
@@ -3511,20 +3541,10 @@ static void getKeyEncoding(rliteClient *c, char *encoding, unsigned char *key, l
|
|
3511
3541
|
RLITE_SERVER_ERR(c, retval);
|
3512
3542
|
int hashtable = 512 < (size_t)len;
|
3513
3543
|
if (!hashtable) {
|
3514
|
-
char o[40];
|
3515
3544
|
int retval = rl_smembers(c->context->db, &iterator, key, keylen);
|
3516
3545
|
RLITE_SERVER_ERR(c, retval);
|
3517
3546
|
while ((retval = rl_set_iterator_next(iterator, &value, &valuelen)) == RL_OK) {
|
3518
|
-
if (valuelen
|
3519
|
-
hashtable = 1;
|
3520
|
-
rl_free(value);
|
3521
|
-
rl_set_iterator_destroy(iterator);
|
3522
|
-
retval = RL_END;
|
3523
|
-
break;
|
3524
|
-
}
|
3525
|
-
memcpy(o, value, sizeof(char) * valuelen);
|
3526
|
-
o[valuelen] = 0;
|
3527
|
-
if (getLongLongFromObject(o, NULL) != RLITE_OK) {
|
3547
|
+
if (getLongLongFromObject((char *)value, valuelen, NULL) != RLITE_OK) {
|
3528
3548
|
hashtable = 1;
|
3529
3549
|
rl_free(value);
|
3530
3550
|
rl_set_iterator_destroy(iterator);
|
@@ -3644,7 +3664,7 @@ static void restoreCommand(rliteClient *c) {
|
|
3644
3664
|
unsigned char *payload = UNSIGN(c->argv[3]);
|
3645
3665
|
long payloadlen = c->argvlen[3];
|
3646
3666
|
long long expires = 0;
|
3647
|
-
if (getLongLongFromObjectOrReply(c, c->argv[2], &expires, RLITE_SYNTAXERR) != RLITE_OK) {
|
3667
|
+
if (getLongLongFromObjectOrReply(c, c->argv[2], c->argvlen[2], &expires, RLITE_SYNTAXERR) != RLITE_OK) {
|
3648
3668
|
return;
|
3649
3669
|
}
|
3650
3670
|
if (expires != 0) {
|
@@ -3719,9 +3739,9 @@ static void sortCommand(rliteClient *c) {
|
|
3719
3739
|
} else if (!strcasecmp(c->argv[j],"alpha")) {
|
3720
3740
|
alpha = 1;
|
3721
3741
|
} else if (!strcasecmp(c->argv[j],"limit") && leftargs >= 2) {
|
3722
|
-
if ((getLongFromObjectOrReply(c, c->argv[j+1], &limit_start, NULL)
|
3742
|
+
if ((getLongFromObjectOrReply(c, c->argv[j+1], c->argvlen[j+1], &limit_start, NULL)
|
3723
3743
|
!= RL_OK) ||
|
3724
|
-
(getLongFromObjectOrReply(c, c->argv[j+2], &limit_count, NULL)
|
3744
|
+
(getLongFromObjectOrReply(c, c->argv[j+2], c->argvlen[j+2], &limit_count, NULL)
|
3725
3745
|
!= RL_OK))
|
3726
3746
|
{
|
3727
3747
|
syntax_error++;
|
@@ -3770,7 +3790,7 @@ static void sortCommand(rliteClient *c) {
|
|
3770
3790
|
c->reply = createErrorObject(RLITE_SYNTAXERR);
|
3771
3791
|
goto cleanup;
|
3772
3792
|
}
|
3773
|
-
retval = rl_sort(c->context->db, (unsigned char *)c->argv[1], c->argvlen[1], sortby, sortbylen, dontsort, alpha, desc, limit_start, limit_count, getc, getv, getvlen, storekey, storekeylen, &objc, &objv, &objvlen);
|
3793
|
+
retval = rl_sort(c->context->db, (unsigned char *)c->argv[1], c->argvlen[1], sortby, sortbylen, dontsort, c->context->inLuaScript, alpha, desc, limit_start, limit_count, getc, getv, getvlen, storekey, storekeylen, &objc, &objv, &objvlen);
|
3774
3794
|
if (retval == RL_NAN) {
|
3775
3795
|
c->reply = createErrorObject("ERR One or more scores can't be converted into double");
|
3776
3796
|
goto cleanup;
|
@@ -3947,10 +3967,10 @@ static struct rliteCommand rliteCommandTable[] = {
|
|
3947
3967
|
{"dump",dumpCommand,2,"ar",0,1,1,1,0,0},
|
3948
3968
|
{"object",objectCommand,3,"r",0,2,2,2,0,0},
|
3949
3969
|
// {"client",clientCommand,-2,"ars",0,NULL,0,0,0,0,0},
|
3950
|
-
|
3951
|
-
|
3970
|
+
{"eval",evalCommand,-3,"s",0,0,0,0,0,0},
|
3971
|
+
{"evalsha",evalShaCommand,-3,"s",0,0,0,0,0,0},
|
3952
3972
|
// {"slowlog",slowlogCommand,-2,"r",0,NULL,0,0,0,0,0},
|
3953
|
-
|
3973
|
+
{"script",scriptCommand,-2,"ras",0,0,0,0,0,0},
|
3954
3974
|
// {"time",timeCommand,1,"rRF",0,NULL,0,0,0,0,0},
|
3955
3975
|
{"bitop",bitopCommand,-4,"wm",0,2,-1,1,0,0},
|
3956
3976
|
{"bitcount",bitcountCommand,-2,"r",0,1,1,1,0,0},
|
@@ -3965,7 +3985,31 @@ static struct rliteCommand rliteCommandTable[] = {
|
|
3965
3985
|
// {"latency",latencyCommand,-2,"arslt",0,NULL,0,0,0,0,0}
|
3966
3986
|
};
|
3967
3987
|
|
3968
|
-
|
3988
|
+
int rliteCommandHasFlag(struct rliteCommand *c, int flags) {
|
3989
|
+
char *f = c->sflags;
|
3990
|
+
|
3991
|
+
while(*f != '\0') {
|
3992
|
+
switch(*f) {
|
3993
|
+
case 'w': c->flags |= RLITE_CMD_WRITE; break;
|
3994
|
+
case 'r': c->flags |= RLITE_CMD_READONLY; break;
|
3995
|
+
case 'm': c->flags |= RLITE_CMD_DENYOOM; break;
|
3996
|
+
case 'a': c->flags |= RLITE_CMD_ADMIN; break;
|
3997
|
+
case 'p': c->flags |= RLITE_CMD_PUBSUB; break;
|
3998
|
+
case 's': c->flags |= RLITE_CMD_NOSCRIPT; break;
|
3999
|
+
case 'R': c->flags |= RLITE_CMD_RANDOM; break;
|
4000
|
+
case 'S': c->flags |= RLITE_CMD_SORT_FOR_SCRIPT; break;
|
4001
|
+
case 'l': c->flags |= RLITE_CMD_LOADING; break;
|
4002
|
+
case 't': c->flags |= RLITE_CMD_STALE; break;
|
4003
|
+
case 'M': c->flags |= RLITE_CMD_SKIP_MONITOR; break;
|
4004
|
+
case 'k': c->flags |= RLITE_CMD_ASKING; break;
|
4005
|
+
case 'F': c->flags |= RLITE_CMD_FAST; break;
|
4006
|
+
}
|
4007
|
+
f++;
|
4008
|
+
}
|
4009
|
+
return flags == 0;
|
4010
|
+
}
|
4011
|
+
|
4012
|
+
struct rliteCommand *rliteLookupCommand(const char *name, size_t len) {
|
3969
4013
|
char _name[100];
|
3970
4014
|
if (len >= 100) {
|
3971
4015
|
return NULL;
|