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-06-07 23:50:22 +0300
committerGitHub <noreply@github.com>2020-06-07 23:50:22 +0300
commit5ca4141c72e23816f146b49877a6a4b8098b34c6 (patch)
treec806c9728eb6c4bafd03349e6c779c493bd7593e /cluster_library.h
parenta0c53e0b30e0c6af15cc137415e7d65f6d1867f7 (diff)
Issue.1765 (#1774)
Various improvements and fixes to cluster slot caching. * Improves slot caching so any unique set of seeds all hash to the same key * Fix a couple of memory leaks. * Fixes a segfault when executing a multiple key command such as `MGET` or `MSET` while the cluster is resharding.
Diffstat (limited to 'cluster_library.h')
-rw-r--r--cluster_library.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/cluster_library.h b/cluster_library.h
index b7a365ef..062db790 100644
--- a/cluster_library.h
+++ b/cluster_library.h
@@ -129,6 +129,8 @@
mc.kw = keyword; \
mc.kw_len = keyword_len; \
+#define CLUSTER_CACHING_ENABLED() (INI_INT("redis.clusters.cache_slots") == 1)
+
/* Cluster redirection enum */
typedef enum CLUSTER_REDIR_TYPE {
REDIR_NONE,
@@ -358,6 +360,15 @@ void cluster_multi_fini(clusterMultiCmd *mc);
unsigned short cluster_hash_key_zval(zval *key);
unsigned short cluster_hash_key(const char *key, int len);
+/* Validate and sanitize cluster construction args */
+zend_string** cluster_validate_args(double timeout, double read_timeout,
+ HashTable *seeds, uint32_t *nseeds, char **errstr);
+
+void free_seed_array(zend_string **seeds, uint32_t nseeds);
+
+/* Generate a unique hash string from seeds array */
+zend_string *cluster_hash_seeds(zend_string **seeds, uint32_t nseeds);
+
/* Get the current time in milliseconds */
long long mstime(void);
@@ -379,7 +390,7 @@ PHP_REDIS_API int cluster_send_slot(redisCluster *c, short slot, char *cmd,
PHP_REDIS_API redisCluster *cluster_create(double timeout, double read_timeout,
int failover, int persistent);
PHP_REDIS_API void cluster_free(redisCluster *c, int free_ctx);
-PHP_REDIS_API int cluster_init_seeds(redisCluster *c, HashTable *ht_seeds);
+PHP_REDIS_API void cluster_init_seeds(redisCluster *c, zend_string **seeds, uint32_t nseeds);
PHP_REDIS_API int cluster_map_keyspace(redisCluster *c);
PHP_REDIS_API void cluster_free_node(redisClusterNode *node);
@@ -390,10 +401,10 @@ PHP_REDIS_API void cluster_init_cache(redisCluster *c, redisCachedCluster *rcc);
/* Functions to facilitate cluster slot caching */
-PHP_REDIS_API char **cluster_sock_read_multibulk_reply(RedisSock *redis_sock,
- int *len);
-PHP_REDIS_API int cluster_cache_store(HashTable *ht_seeds, HashTable *nodes);
-PHP_REDIS_API redisCachedCluster *cluster_cache_load(HashTable *ht_seeds);
+PHP_REDIS_API char **cluster_sock_read_multibulk_reply(RedisSock *redis_sock, int *len);
+
+PHP_REDIS_API int cluster_cache_store(zend_string *hash, HashTable *nodes);
+PHP_REDIS_API redisCachedCluster *cluster_cache_load(zend_string *hash);
/*
* Redis Cluster response handlers. Our response handlers generally take the