Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Grunder <michael.grunder@gmail.com>2020-05-24 00:25:41 +0300
committerGitHub <noreply@github.com>2020-05-24 00:25:41 +0300
commitf9c7bb5788c39614c23e3bb9ec42ec8d6d5bbaa1 (patch)
tree954b79a20393ab658a32b2e93c183a57d278450d /common.h
parentf13f9b7c7f5e3a7d286b412541199a408a0a98bd (diff)
Adds Redis 6.0 KEEPTTL option for SET (#1766)
Added support for KEEPTTL option of SET command, which added in Redis 6 See: #1761 Co-authored-by: victor <viktork@sekindo.com>
Diffstat (limited to 'common.h')
-rw-r--r--common.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/common.h b/common.h
index 1926d641..857e87cf 100644
--- a/common.h
+++ b/common.h
@@ -209,18 +209,26 @@ typedef enum {
REDIS_PROCESS_RESPONSE_CLOSURE(resp_func, ctx) \
}
+/* Case insensitive compare against compile-time static string */
+#define REDIS_STRICMP_STATIC(s, len, sstr) \
+ (len == sizeof(sstr) - 1 && !strncasecmp(s, sstr, len))
+
+/* Test if a zval is a string and (case insensitive) matches a static string */
+#define ZVAL_STRICMP_STATIC(zv, sstr) \
+ REDIS_STRICMP_STATIC(Z_STRVAL_P(zv), Z_STRLEN_P(zv), sstr)
+
+/* Case insensitive compare of a zend_string to a static string */
+#define ZSTR_STRICMP_STATIC(zs, sstr) \
+ REDIS_STRICMP_STATIC(ZSTR_VAL(zs), ZSTR_LEN(zs), sstr)
+
/* Extended SET argument detection */
-#define IS_EX_ARG(a) \
- ((a[0]=='e' || a[0]=='E') && (a[1]=='x' || a[1]=='X') && a[2]=='\0')
-#define IS_PX_ARG(a) \
- ((a[0]=='p' || a[0]=='P') && (a[1]=='x' || a[1]=='X') && a[2]=='\0')
-#define IS_NX_ARG(a) \
- ((a[0]=='n' || a[0]=='N') && (a[1]=='x' || a[1]=='X') && a[2]=='\0')
-#define IS_XX_ARG(a) \
- ((a[0]=='x' || a[0]=='X') && (a[1]=='x' || a[1]=='X') && a[2]=='\0')
-
-#define IS_EX_PX_ARG(a) (IS_EX_ARG(a) || IS_PX_ARG(a))
-#define IS_NX_XX_ARG(a) (IS_NX_ARG(a) || IS_XX_ARG(a))
+#define ZSTR_IS_EX_ARG(zs) ZSTR_STRICMP_STATIC(zs, "EX")
+#define ZSTR_IS_PX_ARG(zs) ZSTR_STRICMP_STATIC(zs, "PX")
+#define ZSTR_IS_NX_ARG(zs) ZSTR_STRICMP_STATIC(zs, "NX")
+#define ZSTR_IS_XX_ARG(zs) ZSTR_STRICMP_STATIC(zs, "XX")
+
+#define ZVAL_IS_NX_XX_ARG(zv) (ZVAL_STRICMP_STATIC(zv, "NX") || ZVAL_STRICMP_STATIC(zv, "XX"))
+#define ZSTR_IS_EX_PX_ARG(a) (ZSTR_IS_EX_ARG(a) || ZSTR_IS_PX_ARG(a))
/* Given a string and length, validate a zRangeByLex argument. The semantics
* here are that the argument must start with '(' or '[' or be just the char