Projects
home:rottame:vhosts-ng:php8-extensions
php8-redis
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 5
View file
php8-redis.changes
Changed
@@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Wed Nov 25 15:07:19 UTC 2026 - Angelo Grossini <angelo@intercom.it> + +- update to 6.3.0 + +------------------------------------------------------------------- Mon May 19 07:14:50 UTC 2025 - Angelo Grossini <angelo@intercom.it> - fix docs
View file
php8-redis.spec
Changed
@@ -18,7 +18,7 @@ %define php_name php8 %define pkg_name redis Name: %{php_name}-%{pkg_name} -Version: 6.2.0 +Version: 6.3.0 Release: lp151.34.1 Summary: API for communicating with Redis servers License: PHP-3.01
View file
redis-6.2.0.tgz/redis-6.2.0/INSTALL.md
Deleted
@@ -1,94 +0,0 @@ -# Installation from pecl - -To pull latest stable released version, from pecl(https://pecl.php.net/package/redis) - -~~~ -pecl install redis -~~~ - -# Installation from sources - -To build this extension for the sources tree: - -~~~ -git clone https://github.com/phpredis/phpredis.git -cd phpredis -phpize -./configure --enable-redis-igbinary --enable-redis-msgpack --enable-redis-lzf --with-liblzf=DIR --enable-redis-zstd --enable-redis-lz4 -make && make install -~~~ - -If you would like phpredis to serialize your data using the igbinary library, run configure with `--enable-redis-igbinary`. -If you would like to use the msgpack serializer, run configure with `--enable-redis-msgpack` (note: Requires php-msgpack >= 2.0.3) -The extension also may compress data before sending it to Redis server, if you run configure with `--enable-redis-lzf`. If you want to use lzf library pre-installed into your system use `--with-liblzf` configuration option to specify the path where to search files. -`make install` copies `redis.so` to an appropriate location, but you still need to enable the module in the PHP config file. To do so, either edit your php.ini or add a redis.ini file in `/etc/php5/conf.d` with the following contents: `extension=redis.so`. - -You can generate a debian package for PHP5, accessible from Apache 2 by running `./mkdeb-apache2.sh` or with `dpkg-buildpackage` or `svn-buildpackage`. - -This extension exports a single class, Redis(./README.md#class-redis) (and RedisException(./README.md#class-redisexception) used in case of errors). Check out https://github.com/ukko/phpredis-phpdoc for a PHP stub that you can use in your IDE for code completion. - - -# Binary packages - -Most distributions provides pre-build binary packages of this extension. - -## Windows: - -Follow the DLL link on the https://pecl.php.net/package/redis(https://pecl.php.net/package/redis) page or use https://windows.php.net/downloads/pecl/releases/redis/(https://windows.php.net/downloads/pecl/releases/redis/) - -## Fedora - -Fedora users can install the package from the official repository. - -### Fedora ≥ 29, Version 5 - -Installation of the php-pecl-redis5(https://packages.fedoraproject.org/pkgs/php-pecl-redis5/php-pecl-redis5/) package: - -~~~ -dnf install php-pecl-redis5 -~~~ - -## RHEL / CentOS - -Installation of the php-pecl-redis(https://apps.fedoraproject.org/packages/php-pecl-redis) package, from the EPEL repository(https://fedoraproject.org/wiki/EPEL): - -~~~ -yum install php-pecl-redis -~~~ - -### openSUSE ≥ 15.1 - -Installation of the php7-redis(https://software.opensuse.org/package/php7-redis?search_term=php7-redis) package: - -~~~ -zypper in php7-redis -~~~ - - -# Installation on OSX - -If the install fails on OSX, type the following commands in your shell before trying again: -~~~ -MACOSX_DEPLOYMENT_TARGET=10.6 -CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" -CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" -CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" -LDFLAGS="-arch i386 -arch x86_64 -bind_at_load" -export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET -~~~ - -If that still fails and you are running Zend Server CE, try this right before "make": `./configure CFLAGS="-arch i386"`. - -Taken from Compiling phpredis on Zend Server CE/OSX (http://www.tumblr.com/tagged/phpredis). - -See also: Install Redis & PHP Extension PHPRedis with Macports(http://www.lecloud.net/post/3378834922/install-redis-php-extension-phpredis-with-macports). - -You can install it using MacPorts: - -- Get macports-php(https://www.macports.org/) -- `sudo port install php56-redis` (or php53-redis, php54-redis, php55-redis, php70-redis, php71-redis, php72-redis, php73-redis, php74-redis) - -# Building on Windows - -See instructions from @char101(https://github.com/phpredis/phpredis/issues/213#issuecomment-11361242) on how to build phpredis on Windows. -
View file
redis-6.2.0.tgz/redis-6.2.0/README.md
Deleted
@@ -1,4570 +0,0 @@ -# PhpRedis - -!Build Status(https://github.com/phpredis/phpredis/actions/workflows/ci.yml/badge.svg)(https://github.com/phpredis/phpredis/actions/workflows/ci.yml) -!Coverity Scan Build Status(https://scan.coverity.com/projects/13205/badge.svg)(https://scan.coverity.com/projects/phpredis-phpredis) -!PHP version(https://img.shields.io/badge/php-%3E%3D%207.0-8892BF.svg)(https://github.com/phpredis/phpredis) - -The phpredis extension provides an API for communicating with the Redis(http://redis.io/) key-value store. It also supports KeyDB(https://docs.keydb.dev/) and Valkey(https://valkey.io/), which are open source alternatives to Redis. - -It is released under the PHP License, version 3.01(http://www.php.net/license/3_01.txt). - -You can send comments, patches, questions here on github(https://github.com/phpredis/phpredis/issues), to michael.grunder@gmail.com (Twitter(https://twitter.com/grumi78), <a rel="me" href="https://phpc.social/@mgrunder">Mastodon</a>), p.yatsukhnenko@gmail.com (@yatsukhnenko(https://twitter.com/yatsukhnenko)), or n.favrefelix@gmail.com (@yowgi(https://twitter.com/yowgi)). - - -## API Documentation(https://phpredis.github.io/phpredis) -These are a work in progress, but will eventually replace our **ONE README TO RULE THEM ALL** docs. - -## Supporting the project -PhpRedis will always be free and open source software, but if you or your company has found it useful please consider supporting the project. Developing a large, complex, and performant library like PhpRedis takes a great deal of time and effort, and support would be appreciated! :heart: - -The best way to support the project is through GitHub sponsors(https://github.com/sponsors/michael-grunder). Many of the reward tiers grant access to our slack channel(https://phpredis.slack.com) where myself(https://github.com/michael-grunder) and Pavlo(https://github.com/yatsukhnenko) are regularly available to answer questions. Additionally this will allow you to provide feedback on which fixes and new features to prioritize. - -You can also make a one-time contribution with !PayPal(https://img.shields.io/badge/Donate-PayPal-green.svg)(https://www.paypal.me/michaelgrunder/5) - -## Sponsors -<a href="https://audiomack.com"><img src="https://styleguide.audiomack.com/assets/dl/inline-orange-large.png" align="center" alt="Audiomack.com" width="150"></a> -<a href="https://bluehost.com"><img src="https://upload.wikimedia.org/wikipedia/commons/2/22/Bluehost-logo.png" align="center" alt="Bluehost.com" width="150"></a> -<a href="https://objectcache.pro"><img src="https://objectcache.pro/assets/wordmark-padded.png" align="center" alt="Object Cache Pro" width="150"></a> -<a href="https://openlms.net"><img src="https://help.openlms.net/wp-content/uploads/2020/05/cropped-open-lms.png" align="center" alt="OpenLMS.net" width="150"></a> - -# Table of contents ------ -1. Installing/Configuring(#installingconfiguring) - * Installation(#installation) - * PHP Session handler(#php-session-handler) - * Distributed Redis Array(./arrays.md#readme) - * Redis Cluster support(./cluster.md#readme) - * Redis Sentinel support(./sentinel.md#readme) - * Running the unit tests(#running-the-unit-tests) -1. Classes and methods(#classes-and-methods) - * Usage(#usage) - * Connection(#connection) - * Retry and backoff(#retry-and-backoff) - * Server(#server) - * Keys and strings(#keys-and-strings) - * Hashes(#hashes) - * Lists(#lists) - * Sets(#sets) - * Sorted sets(#sorted-sets) - * HyperLogLogs(#hyperloglogs) - * Geocoding(#geocoding) - * Streams(#streams) - * Pub/sub(#pubsub) - * Transactions(#transactions) - * Scripting(#scripting) - * Introspection(#introspection) - ------ - -# Installing/Configuring ------ - -## Installation - -For everything you should need to install PhpRedis on your system, -see the INSTALL.md(./INSTALL.md) page. - -## PHP Session handler - -phpredis can be used to store PHP sessions. To do this, configure `session.save_handler` and `session.save_path` in your php.ini to tell phpredis where to store the sessions. - -`session.save_path` can have a simple `host:port` format too, but you need to provide the `tcp://` scheme if you want to use the parameters. The following parameters are available: - -* weight (integer): the weight of a host is used in comparison with the others in order to customize the session distribution on several hosts. If host A has twice the weight of host B, it will get twice the amount of sessions. In the example, *host1* stores 20% of all the sessions (1/(1+2+2)) while *host2* and *host3* each store 40% (2/(1+2+2)). The target host is determined once and for all at the start of the session, and doesn't change. The default weight is 1. -* timeout (float): the connection timeout to a redis host, expressed in seconds. If the host is unreachable in that amount of time, the session storage will be unavailable for the client. The default timeout is very high (86400 seconds). -* persistent (integer, should be 1 or 0): defines if a persistent connection should be used. -* prefix (string, defaults to "PHPREDIS_SESSION:"): used as a prefix to the Redis key in which the session is stored. The key is composed of the prefix followed by the session ID. -* auth (string, or an array with one or two elements): used to authenticate with the server prior to sending commands. -* database (integer): selects a different database. - -Sessions have a lifetime expressed in seconds and stored in the INI variable "session.gc_maxlifetime". You can change it with `ini_set()`(http://php.net/ini_set). -The session handler requires a version of Redis supporting `EX` and `NX` options of `SET` command (at least 2.6.12). -phpredis can also connect to a unix domain socket: `session.save_path = "unix:///var/run/redis/redis.sock?persistent=1&weight=1&database=0"`. - -### Examples - -Multiple Redis servers: -~~~ -session.save_handler = redis -session.save_path = "tcp://host1:6379?weight=1, tcp://host2:6379?weight=2&timeout=2.5, tcp://host3:6379?weight=2&read_timeout=2.5" -~~~ - -Login to Redis using username and password: -~~~ -session.save_handler = redis -session.save_path = "tcp://127.0.0.1:6379?auth=user&auth=password" -~~~ - -Login to Redis using username, password, and set prefix: -~~~ -session.save_handler = redis -session.save_path = "tcp://127.0.0.1:6379?auth=user&auth=password&prefix=user_PHPREDIS_SESSION:" -~~~ - -### Session locking - -**Support**: Locking feature is currently only supported for Redis setup with single master instance (e.g. classic master/slave Sentinel environment). -So locking may not work properly in RedisArray or RedisCluster environments. - -Following INI variables can be used to configure session locking: -~~~ -; Should the locking be enabled? Defaults to: 0. -redis.session.locking_enabled = 1 -; How long should the lock live (in seconds)? Defaults to: value of max_execution_time. -redis.session.lock_expire = 60 -; How long to wait between attempts to acquire lock, in microseconds (µs)?. Defaults to: 20000 -redis.session.lock_wait_time = 50000 -; Maximum number of times to retry (-1 means infinite). Defaults to: 100 -redis.session.lock_retries = 2000 -~~~ - -### Session compression - -Following INI variables can be used to configure session compression: -~~~ -; Should session compression be enabled? Possible values are zstd, lzf, lz4, none. Defaults to: none -redis.session.compression = zstd -; What compression level should be used? Compression level depends on used library. For most deployments range 1-9 should be fine. Defaults to: 3 -redis.session.compression_level = 3 -~~~ - -## Running the unit tests - -phpredis uses a small custom unit test suite for testing functionality of the various classes. To run tests, simply do the following: - -~~~ -# Run tests for Redis class (note this is the default) -php tests/TestRedis.php --class Redis - -# Run tests for RedisArray class -tests/mkring.sh start -php tests/TestRedis.php --class RedisArray -tests/mkring.sh stop - -# Run tests for the RedisCluster class -tests/make-cluster.sh start -php tests/TestRedis.php --class RedisCluster -tests/make-cluster.sh stop - -# Run tests for RedisSentinel class -php tests/TestRedis.php --class RedisSentinel -~~~ - -Note that it is possible to run only tests which match a substring of the test itself by passing the additional argument '--test <str>' when invoking. - -~~~ -# Just run the 'echo' test -php tests/TestRedis.php --class Redis --test echo -~~~ - -# Classes and methods ------ - -## Usage - -1. Class Redis(#class-redis) -1. Class RedisException(#class-redisexception) -1. Predefined constants(#predefined-constants) - -### Class Redis ------ -_**Description**_: Creates a Redis client - -##### *Example* - -~~~php -$redis = new Redis(); -~~~ - -Starting from version 6.0.0 it's possible to specify configuration options. -This allows to connect lazily to the server without explicitly invoking `connect` command. - -##### *Example* - -~~~php -$redis = new Redis( - 'host' => '127.0.0.1', - 'port' => 6379, - 'connectTimeout' => 2.5, - 'auth' => 'phpredis', 'phpredis', - 'ssl' => 'verify_peer' => false, - 'backoff' => - 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, - 'base' => 500, - 'cap' => 750, - , -); -~~~ - -##### *Parameters*
View file
redis-6.2.0.tgz/redis-6.2.0/cluster_library.c
Deleted
@@ -1,3137 +0,0 @@ -#include "php_redis.h" -#include "common.h" -#include "library.h" -#include "redis_commands.h" -#include "cluster_library.h" -#include "crc16.h" -#include <zend_exceptions.h> - -extern zend_class_entry *redis_cluster_exception_ce; -int le_cluster_slot_cache; - -/* Debugging methods/ -static void cluster_dump_nodes(redisCluster *c) { - redisClusterNode *p; - - ZEND_HASH_FOREACH_PTR(c->nodes, p) { - if (p == NULL) { - continue; - } - - const char *slave = (p->slave) ? "slave" : "master"; - php_printf("%d %s %d %d", p->sock->port, slave,p->sock->prefix_len, - p->slot); - - php_printf("\n"); - } ZEND_HASH_FOREACH_END(); -} - -static void cluster_log(char *fmt, ...) -{ - va_list args; - char buffer1024; - - va_start(args, fmt); - vsnprintf(buffer,sizeof(buffer),fmt,args); - va_end(args); - - fprintf(stderr, "%s\n", buffer); -} - -// Debug function to dump a clusterReply structure recursively -static void dump_reply(clusterReply *reply, int indent) { - smart_string buf = {0}; - int i; - - switch(reply->type) { - case TYPE_ERR: - smart_string_appendl(&buf, "(error) ", sizeof("(error) ")-1); - smart_string_appendl(&buf, reply->str, reply->len); - break; - case TYPE_LINE: - smart_string_appendl(&buf, reply->str, reply->len); - break; - case TYPE_INT: - smart_string_appendl(&buf, "(integer) ", sizeof("(integer) ")-1); - smart_string_append_long(&buf, reply->integer); - break; - case TYPE_BULK: - smart_string_appendl(&buf,"\"", 1); - smart_string_appendl(&buf, reply->str, reply->len); - smart_string_appendl(&buf, "\"", 1); - break; - case TYPE_MULTIBULK: - if (reply->elements < 0) { - smart_string_appendl(&buf, "(nil)", sizeof("(nil)")-1); - } else { - for (i = 0; i < reply->elements; i++) { - dump_reply(reply->elementi, indent+2); - } - } - break; - default: - break; - } - - if (buf.len > 0) { - for (i = 0; i < indent; i++) { - php_printf(" "); - } - - smart_string_0(&buf); - php_printf("%s", buf.c); - php_printf("\n"); - - efree(buf.c); - } -} -*/ - - -/* Recursively free our reply object. If free_data is non-zero we'll also free - * the payload data (strings) themselves. If not, we just free the structs */ -void cluster_free_reply(clusterReply *reply, int free_data) { - long long i; - - switch(reply->type) { - case TYPE_ERR: - case TYPE_LINE: - case TYPE_BULK: - if (free_data && reply->str) - efree(reply->str); - break; - case TYPE_MULTIBULK: - if (reply->element) { - if (reply->elements > 0) { - for (i = 0; i < reply->elements && reply->elementi; i++) { - cluster_free_reply(reply->elementi, free_data); - } - } - efree(reply->element); - } - break; - default: - break; - } - efree(reply); -} - -static int -cluster_multibulk_resp_recursive(RedisSock *sock, size_t elements, - clusterReply **element, int status_strings) -{ - int i; - size_t sz; - clusterReply *r; - long len; - char buf1024; - - for (i = 0; i < elements; i++) { - r = elementi = ecalloc(1, sizeof(clusterReply)); - - // Bomb out, flag error condition on a communication failure - if (redis_read_reply_type(sock, &r->type, &len) < 0) { - return FAILURE; - } - - /* Set our reply len */ - r->len = len; - - switch(r->type) { - case TYPE_ERR: - case TYPE_LINE: - if (redis_sock_gets(sock,buf,sizeof(buf),&sz) < 0) { - return FAILURE; - } - r->len = (long long)sz; - if (status_strings) r->str = estrndup(buf, r->len); - break; - case TYPE_INT: - r->integer = len; - break; - case TYPE_BULK: - if (r->len >= 0) { - r->str = redis_sock_read_bulk_reply(sock,r->len); - if (!r->str) { - return FAILURE; - } - } - break; - case TYPE_MULTIBULK: - r->elements = r->len; - if (r->elements > 0) { - r->element = ecalloc(r->len, sizeof(*r->element)); - if (cluster_multibulk_resp_recursive(sock, r->elements, r->element, status_strings) < 0) { - return FAILURE; - } - } - break; - default: - return FAILURE; - } - } - return SUCCESS; -} - -/* Return the socket for a slot and slave index */ -static RedisSock *cluster_slot_sock(redisCluster *c, unsigned short slot, - zend_ulong slaveidx) -{ - redisClusterNode *node; - - /* Return the master if we're not looking for a slave */ - if (slaveidx == 0) { - return SLOT_SOCK(c, slot); - } - - /* Abort if we can't find this slave */ - if (!SLOT_SLAVES(c, slot) || - (node = zend_hash_index_find_ptr(SLOT_SLAVES(c,slot), slaveidx)) == NULL - ) { - return NULL; - } - - /* Success, return the slave */ - return node->sock; -} - -/* Read the response from a cluster */ -clusterReply *cluster_read_resp(redisCluster *c, int status_strings) {
View file
redis-6.2.0.tgz/redis-6.2.0/cluster_library.h
Deleted
@@ -1,537 +0,0 @@ -#ifndef _PHPREDIS_CLUSTER_LIBRARY_H -#define _PHPREDIS_CLUSTER_LIBRARY_H - -#include "common.h" - -#ifdef ZTS -#include "TSRM.h" -#endif - -/* Redis cluster hash slots and N-1 which we'll use to find it */ -#define REDIS_CLUSTER_SLOTS 16384 -#define REDIS_CLUSTER_MOD (REDIS_CLUSTER_SLOTS-1) - -/* Complete representation for various commands in RESP */ -#define RESP_UNWATCH_CMD "*1\r\n$7\r\nUNWATCH\r\n" -#define RESP_CLUSTER_SLOTS_CMD "*2\r\n$7\r\nCLUSTER\r\n$5\r\nSLOTS\r\n" -#define RESP_ASKING_CMD "*1\r\n$6\r\nASKING\r\n" -#define RESP_READONLY_CMD "*1\r\n$8\r\nREADONLY\r\n" -#define RESP_READWRITE_CMD "*1\r\n$9\r\nREADWRITE\r\n" - -#define RESP_READONLY_CMD_LEN (sizeof(RESP_READONLY_CMD)-1) - -/* MOVED/ASK comparison macros */ -#define IS_MOVED(p) (p0=='M' && p1=='O' && p2=='V' && p3=='E' && \ - p4=='D' && p5==' ') -#define IS_ASK(p) (p0=='A' && p1=='S' && p2=='K' && p3==' ') - -/* MOVED/ASK lengths */ -#define MOVED_LEN (sizeof("MOVED ")-1) -#define ASK_LEN (sizeof("ASK ")-1) - -/* Initial allocation size for key distribution container */ -#define CLUSTER_KEYDIST_ALLOC 8 - -/* Macros to access nodes, sockets, and streams for a given slot */ -#define SLOT(c,s) (c->masters) -#define SLOT_SOCK(c,s) (SLOT(c,s)->sock) -#define SLOT_STREAM(c,s) (SLOT_SOCK(c,s)->stream) -#define SLOT_SLAVES(c,s) (c->masters->slaves) - -/* Compare redirection slot information with the passed node */ -#define CLUSTER_REDIR_CMP(c, sock) \ - (sock->port != c->redir_port || \ - ZSTR_LEN(sock->host) != c->redir_host_len || \ - memcmp(ZSTR_VAL(sock->host),c->redir_host,c->redir_host_len)) - -/* Clear out our "last error" */ -#define CLUSTER_CLEAR_ERROR(c) do { \ - if (c->err) { \ - zend_string_release(c->err); \ - c->err = NULL; \ - } \ - c->clusterdown = 0; \ -} while (0) - -/* Protected sending of data down the wire to a RedisSock->stream */ -#define CLUSTER_SEND_PAYLOAD(sock, buf, len) \ - (sock && !redis_sock_server_open(sock) && sock->stream && !redis_check_eof(sock, 0, 1) && \ - redis_sock_write_raw(sock, buf, len) == len) - -/* Macro to read our reply type character */ -#define CLUSTER_VALIDATE_REPLY_TYPE(sock, type) \ - (redis_check_eof(sock, 1, 1) == 0 && redis_sock_getc(sock) == type) - -/* Reset our last single line reply buffer and length */ -#define CLUSTER_CLEAR_REPLY(c) \ - *c->line_reply = '\0'; c->reply_len = 0; - -/* Helper to determine if we're in MULTI mode */ -#define CLUSTER_IS_ATOMIC(c) (c->flags->mode != MULTI) - -/* Helper that either returns false or adds false in multi mode */ -#define CLUSTER_RETURN_FALSE(c) \ - if(CLUSTER_IS_ATOMIC(c)) { \ - RETURN_FALSE; \ - } else { \ - add_next_index_bool(&c->multi_resp, 0); \ - return; \ - } - -/* Helper to either return a bool value or add it to MULTI response */ -#define CLUSTER_RETURN_BOOL(c, b) \ - if(CLUSTER_IS_ATOMIC(c)) { \ - RETURN_BOOL(b); \ - } else { \ - add_next_index_bool(&c->multi_resp, b); \ - } - -/* Helper to respond with a double or add it to our MULTI response */ -#define CLUSTER_RETURN_DOUBLE(c, d) \ - if(CLUSTER_IS_ATOMIC(c)) { \ - RETURN_DOUBLE(d); \ - } else { \ - add_next_index_double(&c->multi_resp, d); \ - } - -/* Helper to return a string value */ -#define CLUSTER_RETURN_STRING(c, str, len) \ - if(CLUSTER_IS_ATOMIC(c)) { \ - RETVAL_STRINGL(str, len); \ - } else { \ - add_next_index_stringl(&c->multi_resp, str, len); \ - } \ - -/* Return a LONG value */ -#define CLUSTER_RETURN_LONG(c, val) \ - if(CLUSTER_IS_ATOMIC(c)) { \ - RETURN_LONG(val); \ - } else { \ - add_next_index_long(&c->multi_resp, val); \ - } - -/* Macro to clear out a clusterMultiCmd structure */ -#define CLUSTER_MULTI_CLEAR(mc) \ - mc->cmd.len = 0; \ - mc->args.len = 0; \ - mc->argc = 0; \ - -/* Initialize a clusterMultiCmd with a keyword and length */ -#define CLUSTER_MULTI_INIT(mc, keyword, keyword_len) \ - 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, - REDIR_MOVED, - REDIR_ASK -} CLUSTER_REDIR_TYPE; - -/* MULTI BULK response callback typedef */ -typedef int (*mbulk_cb)(RedisSock*,zval*,long long, void*); - -/* A list of covered slot ranges */ -typedef struct redisSlotRange { - unsigned short low; - unsigned short high; -} redisSlotRange; - -/* Simple host/port information for our cache */ -typedef struct redisCachedHost { - zend_string *addr; - unsigned short port; -} redisCachedHost; - -/* Storage for a cached master node */ -typedef struct redisCachedMaster { - redisCachedHost host; - - redisSlotRange *slot; /* Slots and count */ - size_t slots; - - redisCachedHost *slave; /* Slaves and their count */ - size_t slaves; -} redisCachedMaster; - -typedef struct redisCachedCluster { - // int rsrc_id; /* Zend resource ID */ - zend_string *hash; /* What we're cached by */ - redisCachedMaster *master; /* Array of masters */ - size_t count; /* Number of masters */ -} redisCachedCluster; - -/* A Redis Cluster master node */ -typedef struct redisClusterNode { - RedisSock *sock; /* Our Redis socket in question */ - short slot; /* One slot we believe this node serves */ - zend_llist slots; /* List of all slots we believe this node serves */ - unsigned short slave; /* Are we a slave */ - HashTable *slaves; /* Hash table of slaves */ -} redisClusterNode; - -/* Forward declarations */ -typedef struct clusterFoldItem clusterFoldItem; - -/* RedisCluster implementation structure */ -typedef struct redisCluster { - - /* One RedisSock struct for serialization and prefix information */ - RedisSock *flags; - - /* How long in milliseconds should we wait when being bounced around */ - long waitms; - - /* Are we flagged as being in readonly mode, meaning we could fall back to - * a given master's slave */ - short readonly; - - /* RedisCluster failover options (never, on error, to load balance) */ - short failover; - - /* Hash table of seed host/ports */ - HashTable *seeds; - - /* RedisCluster masters, by direct slot */ - redisClusterNode *masterREDIS_CLUSTER_SLOTS; -
View file
redis-6.2.0.tgz/redis-6.2.0/common.h
Deleted
@@ -1,362 +0,0 @@ -#include "php.h" -#include "php_ini.h" - -#ifndef REDIS_COMMON_H -#define REDIS_COMMON_H - -#define PHPREDIS_CTX_PTR ((char *)0xDEADC0DE) -#define PHPREDIS_NOTUSED(v) ((void)v) - -#include "zend_llist.h" -#include <ext/standard/php_var.h> -#include <ext/standard/php_math.h> -#include <zend_smart_str.h> -#include <ext/standard/php_smart_string.h> - -#define PHPREDIS_GET_OBJECT(class_entry, o) (class_entry *)((char *)o - XtOffsetOf(class_entry, std)) -#define PHPREDIS_ZVAL_GET_OBJECT(class_entry, z) PHPREDIS_GET_OBJECT(class_entry, Z_OBJ_P(z)) - -/* We'll fallthrough if we want to */ -#ifndef __has_attribute -#define __has_attribute(x) 0 -#endif -#if __has_attribute(__fallthrough__) -#define REDIS_FALLTHROUGH __attribute__((__fallthrough__)) -#else -#define REDIS_FALLTHROUGH do { } while (0) -#endif - -/* NULL check so Eclipse doesn't go crazy */ -#ifndef NULL -#define NULL ((void *) 0) -#endif - -#include "backoff.h" - -typedef enum { - REDIS_SOCK_STATUS_FAILED = -1, - REDIS_SOCK_STATUS_DISCONNECTED, - REDIS_SOCK_STATUS_CONNECTED, - REDIS_SOCK_STATUS_AUTHENTICATED, - REDIS_SOCK_STATUS_READY -} redis_sock_status; - -#define _NL "\r\n" - -/* properties */ -#define REDIS_NOT_FOUND 0 -#define REDIS_STRING 1 -#define REDIS_SET 2 -#define REDIS_LIST 3 -#define REDIS_ZSET 4 -#define REDIS_HASH 5 -#define REDIS_STREAM 6 - -#ifdef PHP_WIN32 -#define PHP_REDIS_API __declspec(dllexport) -#define phpredis_atoi64(p) _atoi64((p)) -#else -#define PHP_REDIS_API -#define phpredis_atoi64(p) atoll((p)) -#endif - -/* reply types */ -typedef enum _REDIS_REPLY_TYPE { - TYPE_EOF = -1, - TYPE_LINE = '+', - TYPE_INT = ':', - TYPE_ERR = '-', - TYPE_BULK = '$', - TYPE_MULTIBULK = '*' -} REDIS_REPLY_TYPE; - -/* SCAN variants */ -typedef enum _REDIS_SCAN_TYPE { - TYPE_SCAN, - TYPE_SSCAN, - TYPE_HSCAN, - TYPE_ZSCAN -} REDIS_SCAN_TYPE; - -/* PUBSUB subcommands */ -typedef enum _PUBSUB_TYPE { - PUBSUB_CHANNELS, - PUBSUB_NUMSUB, - PUBSUB_NUMPAT -} PUBSUB_TYPE; - -#define REDIS_SUBSCRIBE_IDX 0 -#define REDIS_PSUBSCRIBE_IDX 1 -#define REDIS_SSUBSCRIBE_IDX 2 -#define REDIS_SUBS_BUCKETS 3 - -/* options */ -#define REDIS_OPT_SERIALIZER 1 -#define REDIS_OPT_PREFIX 2 -#define REDIS_OPT_READ_TIMEOUT 3 -#define REDIS_OPT_SCAN 4 -#define REDIS_OPT_FAILOVER 5 -#define REDIS_OPT_TCP_KEEPALIVE 6 -#define REDIS_OPT_COMPRESSION 7 -#define REDIS_OPT_REPLY_LITERAL 8 -#define REDIS_OPT_COMPRESSION_LEVEL 9 -#define REDIS_OPT_NULL_MBULK_AS_NULL 10 -#define REDIS_OPT_MAX_RETRIES 11 -#define REDIS_OPT_BACKOFF_ALGORITHM 12 -#define REDIS_OPT_BACKOFF_BASE 13 -#define REDIS_OPT_BACKOFF_CAP 14 -#define REDIS_OPT_PACK_IGNORE_NUMBERS 15 - -/* cluster options */ -#define REDIS_FAILOVER_NONE 0 -#define REDIS_FAILOVER_ERROR 1 -#define REDIS_FAILOVER_DISTRIBUTE 2 -#define REDIS_FAILOVER_DISTRIBUTE_SLAVES 3 -/* serializers */ -typedef enum { - REDIS_SERIALIZER_NONE, - REDIS_SERIALIZER_PHP, - REDIS_SERIALIZER_IGBINARY, - REDIS_SERIALIZER_MSGPACK, - REDIS_SERIALIZER_JSON -} redis_serializer; -/* compression */ -#define REDIS_COMPRESSION_NONE 0 -#define REDIS_COMPRESSION_LZF 1 -#define REDIS_COMPRESSION_ZSTD 2 -#define REDIS_COMPRESSION_LZ4 3 - -/* SCAN options */ -#define REDIS_SCAN_NORETRY 0 -#define REDIS_SCAN_RETRY 1 -#define REDIS_SCAN_PREFIX 2 -#define REDIS_SCAN_NOPREFIX 3 - -/* BACKOFF_ALGORITHM options */ -#define REDIS_BACKOFF_ALGORITHMS 7 -#define REDIS_BACKOFF_ALGORITHM_DEFAULT 0 -#define REDIS_BACKOFF_ALGORITHM_DECORRELATED_JITTER 1 -#define REDIS_BACKOFF_ALGORITHM_FULL_JITTER 2 -#define REDIS_BACKOFF_ALGORITHM_EQUAL_JITTER 3 -#define REDIS_BACKOFF_ALGORITHM_EXPONENTIAL 4 -#define REDIS_BACKOFF_ALGORITHM_UNIFORM 5 -#define REDIS_BACKOFF_ALGORITHM_CONSTANT 6 - -/* GETBIT/SETBIT offset range limits */ -#define BITOP_MIN_OFFSET 0 -#define BITOP_MAX_OFFSET 4294967295U - -/* Transaction modes */ -#define ATOMIC 0 -#define MULTI 1 -#define PIPELINE 2 - -#define PHPREDIS_DEBUG_LOGGING 0 -#define PHPREDIS_WITH_METADATA 1 - -#if PHP_VERSION_ID < 80000 -#define Z_PARAM_ARRAY_HT_OR_NULL(dest) \ - Z_PARAM_ARRAY_HT_EX(dest, 1, 0) -#define Z_PARAM_STR_OR_NULL(dest) \ - Z_PARAM_STR_EX(dest, 1, 0) -#define Z_PARAM_ZVAL_OR_NULL(dest) \ - Z_PARAM_ZVAL_EX(dest, 1, 0) -#define Z_PARAM_BOOL_OR_NULL(dest, is_null) \ - Z_PARAM_BOOL_EX(dest, is_null, 1, 0) -#endif - -#if PHPREDIS_DEBUG_LOGGING == 1 -#define redisDbgFmt(fmt, ...) \ - php_printf("%s:%d:%s(): " fmt "\n", __FILE__, __LINE__, __func__, __VA_ARGS__) -#define redisDbgStr(str) phpredisDebugFmt("%s", str) -#else -#define redisDbgFmt(fmt, ...) ((void)0) -#define redisDbgStr(str) ((void)0) -#endif - -#define IS_ATOMIC(redis_sock) (redis_sock->mode == ATOMIC) -#define IS_MULTI(redis_sock) (redis_sock->mode & MULTI) -#define IS_PIPELINE(redis_sock) (redis_sock->mode & PIPELINE) - -#define PIPELINE_ENQUEUE_COMMAND(cmd, cmd_len) do { \ - smart_string_appendl(&redis_sock->pipeline_cmd, cmd, cmd_len); \ -} while (0) - -#define REDIS_SAVE_CALLBACK(callback, closure_context) do { \ - fold_item *fi = redis_add_reply_callback(redis_sock); \ - fi->fun = callback; \ - fi->flags = redis_sock->flags; \ - fi->ctx = closure_context; \ -} while (0) - -#define REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len) \ - if (IS_PIPELINE(redis_sock)) { \ - PIPELINE_ENQUEUE_COMMAND(cmd, cmd_len); \ - } else if (redis_sock_write(redis_sock, cmd, cmd_len) < 0) { \ - efree(cmd); \ - RETURN_FALSE; \ - } \ - efree(cmd);
View file
redis-6.2.0.tgz/redis-6.2.0/library.c
Deleted
@@ -1,4680 +0,0 @@ -#include "php_redis.h" - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "common.h" -#include "php_network.h" -#include <sys/types.h> - -#ifdef HAVE_REDIS_IGBINARY -#include "igbinary/igbinary.h" -#endif -#ifdef HAVE_REDIS_MSGPACK -#include "msgpack/php_msgpack.h" -#endif - -#ifdef HAVE_REDIS_LZF -#include <lzf.h> - - #ifndef LZF_MARGIN - #define LZF_MARGIN 128 - #endif -#endif - -#ifdef HAVE_REDIS_ZSTD -#include <zstd.h> -#endif - -#ifdef HAVE_REDIS_LZ4 -#include <lz4.h> -#include <lz4hc.h> - -/* uint8_t crf + int length */ -#define REDIS_LZ4_HDR_SIZE (sizeof(uint8_t) + sizeof(int)) -#if defined(LZ4HC_CLEVEL_MAX) -/* version >= 1.7.5 */ -#define REDIS_LZ4_MAX_CLEVEL LZ4HC_CLEVEL_MAX - -#elif defined (LZ4HC_MAX_CLEVEL) -/* version >= 1.7.3 */ -#define REDIS_LZ4_MAX_CLEVEL LZ4HC_MAX_CLEVEL - -#else -/* older versions */ -#define REDIS_LZ4_MAX_CLEVEL 12 -#endif -#endif - -#include <zend_exceptions.h> -#include "php_redis.h" -#include "library.h" -#include "redis_commands.h" - -#ifdef HAVE_REDIS_JSON -#include <ext/json/php_json.h> -#endif - -#include <ext/hash/php_hash.h> - -#if PHP_VERSION_ID < 80400 -#include <ext/standard/php_rand.h> -#else -#include <ext/random/php_random.h> -#endif - -#define UNSERIALIZE_NONE 0 -#define UNSERIALIZE_KEYS 1 -#define UNSERIALIZE_VALS 2 -#define UNSERIALIZE_ALL 3 - -#define SCORE_DECODE_NONE 0 -#define SCORE_DECODE_INT 1 -#define SCORE_DECODE_DOUBLE 2 - -#define REDIS_CALLBACKS_INIT_SIZE 8 -#define REDIS_CALLBACKS_MAX_DOUBLE 32768 -#define REDIS_CALLBACKS_ADD_SIZE 4096 - -/* PhpRedis often returns either FALSE or NULL depending on whether we have - * an option set, so this macro just wraps that often repeated logic */ -#define REDIS_ZVAL_NULL(sock_, zv_) \ - do { \ - if ((sock_)->null_mbulk_as_null) { \ - ZVAL_NULL((zv_)); \ - } else { \ - ZVAL_FALSE((zv_)); \ - } \ - } while (0) - -#ifndef PHP_WIN32 - #include <netinet/tcp.h> /* TCP_NODELAY */ - #include <sys/socket.h> /* SO_KEEPALIVE */ -#else - #include <winsock.h> -#endif - -extern zend_class_entry *redis_ce; -extern zend_class_entry *redis_exception_ce; - -extern int le_redis_pconnect; - -static int redis_mbulk_reply_zipped_raw_variant(RedisSock *redis_sock, zval *zret, int count); - -/* Register a persistent resource in a a way that works for every PHP 7 version. */ -void redis_register_persistent_resource(zend_string *id, void *ptr, int le_id) { - zend_register_persistent_resource(ZSTR_VAL(id), ZSTR_LEN(id), ptr, le_id); -} - -/* Do not allocate empty string or string with one character */ -static zend_always_inline void redis_add_next_index_stringl(zval *arg, const char *str, size_t length) { - zval tmp; - ZVAL_STRINGL_FAST(&tmp, str, length); - zend_hash_next_index_insert(Z_ARRVAL_P(arg), &tmp); -} - -static ConnectionPool * -redis_sock_get_connection_pool(RedisSock *redis_sock) -{ - ConnectionPool *pool; - zend_resource *le; - zend_string *persistent_id; - - /* Generate our unique pool id depending on configuration */ - persistent_id = redis_pool_spprintf(redis_sock, INI_STR("redis.pconnect.pool_pattern")); - - /* Return early if we can find the pool */ - if ((le = zend_hash_find_ptr(&EG(persistent_list), persistent_id))) { - zend_string_release(persistent_id); - return le->ptr; - } - - /* Create the pool and store it in our persistent list */ - pool = pecalloc(1, sizeof(*pool), 1); - zend_llist_init(&pool->list, sizeof(php_stream *), NULL, 1); - redis_register_persistent_resource(persistent_id, pool, le_redis_pconnect); - - zend_string_release(persistent_id); - return pool; -} - -/* Helper to reselect the proper DB number when we reconnect */ -static int reselect_db(RedisSock *redis_sock) { - char *cmd, *response; - int cmd_len, response_len; - - cmd_len = redis_spprintf(redis_sock, NULL, &cmd, "SELECT", "d", - redis_sock->dbNumber); - - if (redis_sock_write(redis_sock, cmd, cmd_len) < 0) { - efree(cmd); - return -1; - } - - efree(cmd); - - if ((response = redis_sock_read(redis_sock, &response_len)) == NULL) { - return -1; - } - - if (redis_strncmp(response, ZEND_STRL("+OK"))) { - efree(response); - return -1; - } - - efree(response); - return 0; -} - -/* Append an AUTH command to a smart string if necessary. This will either - * append the new style AUTH <user> <password>, old style AUTH <password>, or - * append no command at all. Function returns 1 if we appended a command - * and 0 otherwise. */ -static int redis_sock_append_auth(RedisSock *redis_sock, smart_string *str) { - /* We need a password at least */ - if (redis_sock->pass == NULL) - return 0; - - REDIS_CMD_INIT_SSTR_STATIC(str, !!redis_sock->user + !!redis_sock->pass, "AUTH"); - - if (redis_sock->user) - redis_cmd_append_sstr_zstr(str, redis_sock->user); - - redis_cmd_append_sstr_zstr(str, redis_sock->pass); - - /* We appended a command */ - return 1; -} - -PHP_REDIS_API void -redis_sock_set_auth(RedisSock *redis_sock, zend_string *user, zend_string *pass) -{ - /* Release existing user/pass */ - redis_sock_free_auth(redis_sock); - - /* Set new user/pass */ - redis_sock->user = user ? zend_string_copy(user) : NULL; - redis_sock->pass = pass ? zend_string_copy(pass) : NULL; -}
View file
redis-6.2.0.tgz/redis-6.2.0/library.h
Deleted
@@ -1,297 +0,0 @@ -#ifndef REDIS_LIBRARY_H -#define REDIS_LIBRARY_H - -/* Non cluster command helper */ -#define REDIS_SPPRINTF(ret, kw, fmt, ...) \ - redis_spprintf(redis_sock, NULL, ret, kw, fmt, ##__VA_ARGS__) - -#define REDIS_CMD_APPEND_SSTR_STATIC(sstr, str) \ - redis_cmd_append_sstr(sstr, str, sizeof(str)-1); - -#define REDIS_CMD_APPEND_SSTR_OPT_STATIC(sstr, opt, str) \ - if (opt) REDIS_CMD_APPEND_SSTR_STATIC(sstr, str); - -#define REDIS_CMD_INIT_SSTR_STATIC(sstr, argc, keyword) \ - redis_cmd_init_sstr(sstr, argc, keyword, sizeof(keyword)-1); - -#define REDIS_THROW_EXCEPTION(msg, code) \ - zend_throw_exception(redis_exception_ce, (msg), code) - -#define CLUSTER_THROW_EXCEPTION(msg, code) \ - zend_throw_exception(redis_cluster_exception_ce, (msg), code) - -#define redis_sock_write_sstr(redis_sock, sstr) \ - redis_sock_write(redis_sock, (sstr)->c, (sstr)->len) - -#if PHP_VERSION_ID < 80000 - #define redis_hash_fetch_ops(zstr) php_hash_fetch_ops(ZSTR_VAL((zstr)), ZSTR_LEN((zstr))) - - /* use RedisException when ValueError not available */ - #define REDIS_VALUE_EXCEPTION(m) REDIS_THROW_EXCEPTION(m, 0) - #define RETURN_THROWS() RETURN_FALSE - /* ZVAL_STRINGL_FAST and RETVAL_STRINGL_FAST macros are supported since PHP 8 */ - #define ZVAL_STRINGL_FAST(z, s, l) ZVAL_STRINGL(z, s, l) - #define RETVAL_STRINGL_FAST(s, l) RETVAL_STRINGL(s, l) -#else - #define redis_hash_fetch_ops(zstr) php_hash_fetch_ops(zstr) - - #define REDIS_VALUE_EXCEPTION(m) zend_value_error(m) -#endif - - -void redis_register_persistent_resource(zend_string *id, void *ptr, int le_id); -fold_item* redis_add_reply_callback(RedisSock *redis_sock); -void redis_free_reply_callbacks(RedisSock *redis_sock); - -PHP_REDIS_API int redis_extract_auth_info(zval *ztest, zend_string **user, zend_string **pass); -PHP_REDIS_API void redis_with_metadata(zval *zdst, zval *zsrc, zend_long length); - -int redis_cmd_init_sstr(smart_string *str, int num_args, char *keyword, int keyword_len); -int redis_cmd_append_sstr(smart_string *str, char *append, int append_len); -int redis_cmd_append_sstr_int(smart_string *str, int append); -int redis_cmd_append_sstr_long(smart_string *str, long append); -int redis_cmd_append_sstr_i64(smart_string *str, int64_t append); -int redis_cmd_append_sstr_u64(smart_string *str, uint64_t append); -int redis_cmd_append_sstr_dbl(smart_string *str, double value); -int redis_cmd_append_sstr_zstr(smart_string *str, zend_string *zstr); -int redis_cmd_append_sstr_zval(smart_string *str, zval *z, RedisSock *redis_sock); -int redis_cmd_append_sstr_key(smart_string *str, char *key, size_t len, RedisSock *redis_sock, short *slot); -int redis_cmd_append_sstr_key_zstr(smart_string *str, zend_string *key, RedisSock *redis_sock, short *slot); -int redis_cmd_append_sstr_key_zval(smart_string *dst, zval *zv, RedisSock *redis_sock, short *slot); -int redis_cmd_append_sstr_key_long(smart_string *dst, zend_long lval, RedisSock *redis_sock, short *slot); -int redis_cmd_append_sstr_arrkey(smart_string *cmd, zend_string *kstr, zend_ulong idx); - -PHP_REDIS_API int redis_spprintf(RedisSock *redis_sock, short *slot, char **ret, char *kw, char *fmt, ...); -PHP_REDIS_API zend_string *redis_pool_spprintf(RedisSock *redis_sock, char *fmt, ...); - -PHP_REDIS_API char *redis_sock_read(RedisSock *redis_sock, int *buf_len); -PHP_REDIS_API int redis_sock_gets(RedisSock *redis_sock, char *buf, int buf_size, size_t* line_len); -PHP_REDIS_API int redis_1_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_long_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval* z_tab, void *ctx); -typedef void (*SuccessCallback)(RedisSock *redis_sock); -PHP_REDIS_API int redis_boolean_response_impl(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx, SuccessCallback success_callback); -PHP_REDIS_API int redis_boolean_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_bulk_double_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_string_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_ping_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_info_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_config_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_zrange_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API void redis_parse_info_response(char *response, zval *z_ret); -PHP_REDIS_API void redis_parse_client_list_response(char *response, zval *z_ret); -PHP_REDIS_API int redis_type_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API RedisSock* redis_sock_create(char *host, int host_len, int port, double timeout, double read_timeout, int persistent, char *persistent_id, long retry_interval); -PHP_REDIS_API int redis_sock_configure(RedisSock *redis_sock, HashTable *opts); -PHP_REDIS_API int redis_sock_connect(RedisSock *redis_sock); -PHP_REDIS_API int redis_sock_server_open(RedisSock *redis_sock); -PHP_REDIS_API int redis_sock_auth(RedisSock *redis_sock); -PHP_REDIS_API char *redis_sock_auth_cmd(RedisSock *redis_sock, int *cmdlen); -PHP_REDIS_API void redis_sock_set_auth(RedisSock *redis_sock, zend_string *user, zend_string *pass); -PHP_REDIS_API void redis_sock_set_auth_zval(RedisSock *redis_sock, zval *zv); -PHP_REDIS_API void redis_sock_free_auth(RedisSock *redis_sock); -PHP_REDIS_API int redis_sock_disconnect(RedisSock *redis_sock, int force, int is_reset_mode); -PHP_REDIS_API zval *redis_sock_read_multibulk_reply_zval(RedisSock *redis_sock, zval *z_tab); -PHP_REDIS_API int redis_sock_read_single_line(RedisSock *redis_sock, char *buffer, - size_t buflen, size_t *linelen, int set_err); -PHP_REDIS_API char *redis_sock_read_bulk_reply(RedisSock *redis_sock, int bytes); -PHP_REDIS_API int redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *_z_tab, void *ctx); -PHP_REDIS_API void redis_mbulk_reply_loop(RedisSock *redis_sock, zval *z_tab, int count, int unserialize); - - -PHP_REDIS_API int redis_mbulk_reply_raw(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_mbulk_reply_zipped_raw(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_mbulk_reply_zipped_vals(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_mbulk_reply_zipped_keys_int(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_mbulk_reply_zipped_keys_dbl(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_mbulk_reply_assoc(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_mbulk_reply_double(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); - -void redisSetScanCursor(zval *zv, uint64_t cursor); -uint64_t redisGetScanCursor(zval *zv, zend_bool *was_zero); - -PHP_REDIS_API int redis_sock_read_scan_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, REDIS_SCAN_TYPE type, uint64_t *cursor); - -PHP_REDIS_API int redis_xrange_reply(INTERNAL_FUNCTION_PARAMETERS, - RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_xread_reply(INTERNAL_FUNCTION_PARAMETERS, - RedisSock *redis_sock, zval *z_tab, void *ctx); - -PHP_REDIS_API int redis_xclaim_reply(INTERNAL_FUNCTION_PARAMETERS, - RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_read_xclaim_reply( - RedisSock *redis_sock, int count, int is_xautoclaim, zval *rv); - -PHP_REDIS_API int redis_xinfo_reply(INTERNAL_FUNCTION_PARAMETERS, - RedisSock *redis_sock, zval *z_tab, void *ctx); - -PHP_REDIS_API int redis_pubsub_response(INTERNAL_FUNCTION_PARAMETERS, - RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_subscribe_response(INTERNAL_FUNCTION_PARAMETERS, - RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_unsubscribe_response(INTERNAL_FUNCTION_PARAMETERS, - RedisSock *redis_sock, zval *z_tab, void *ctx); - -PHP_REDIS_API int redis_sock_write(RedisSock *redis_sock, char *cmd, size_t sz); -PHP_REDIS_API int redis_check_eof(RedisSock *redis_sock, zend_bool no_retry, zend_bool no_throw); -PHP_REDIS_API RedisSock *redis_sock_get(zval *id, int nothrow); -PHP_REDIS_API void redis_free_socket(RedisSock *redis_sock); -PHP_REDIS_API void redis_sock_set_err(RedisSock *redis_sock, const char *msg, int msg_len); -PHP_REDIS_API int redis_sock_set_stream_context(RedisSock *redis_sock, zval *options); -PHP_REDIS_API int redis_sock_set_backoff(RedisSock *redis_sock, zval *options); - -PHP_REDIS_API int -redis_serialize(RedisSock *redis_sock, zval *z, char **val, size_t *val_len); -PHP_REDIS_API int -redis_key_prefix(RedisSock *redis_sock, char **key, size_t *key_len); -PHP_REDIS_API zend_string* -redis_key_prefix_zval(RedisSock *redis_sock, zval *zv); -PHP_REDIS_API zend_string * -redis_key_prefix_zstr(RedisSock *redis_sock, zend_string *key); - -PHP_REDIS_API int -redis_unserialize(RedisSock *redis_sock, const char *val, int val_len, zval *z_ret); - -PHP_REDIS_API int -redis_compress(RedisSock *redis_sock, char **dst, size_t *dstlen, char *buf, size_t len); -PHP_REDIS_API int -redis_uncompress(RedisSock *redis_sock, char **dst, size_t *dstlen, const char *src, size_t len); - -PHP_REDIS_API int redis_pack(RedisSock *redis_sock, zval *z, char **val, size_t *val_len); -PHP_REDIS_API int redis_unpack(RedisSock *redis_sock, const char *val, int val_len, zval *z_ret); - -PHP_REDIS_API int -redis_read_stream_messages(RedisSock *redis_sock, int count, zval *z_ret); -PHP_REDIS_API int -redis_read_stream_messages_multi(RedisSock *redis_sock, int count, zval *z_ret); -PHP_REDIS_API int -redis_read_xinfo_response(RedisSock *redis_sock, zval *z_ret, int elements); - -PHP_REDIS_API int -redis_mpop_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - zval *z_tab, void *ctx); - -PHP_REDIS_API int -redis_read_mpop_response(RedisSock *redis_sock, zval *zdst, int elements, void *ctx); - -/* Specialized ACL reply handlers */ -PHP_REDIS_API int redis_acl_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_read_acl_getuser_reply(RedisSock *redis_sock, zval *zret, long len); -PHP_REDIS_API int redis_acl_getuser_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_read_acl_log_reply(RedisSock *redis_sock, zval *zret, long count); -PHP_REDIS_API int redis_acl_log_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); - -/* -* Variant Read methods, mostly to implement eval -*/ - -PHP_REDIS_API int redis_read_reply_type(RedisSock *redis_sock, REDIS_REPLY_TYPE *reply_type, long *reply_info); -PHP_REDIS_API int redis_read_variant_bulk(RedisSock *redis_sock, int size, zval *z_ret); -PHP_REDIS_API int redis_read_multibulk_recursive(RedisSock *redis_sock, long long elements, int status_strings, zval *z_ret); -PHP_REDIS_API int redis_read_variant_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_read_raw_variant_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_read_variant_reply_strings(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_client_list_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); - -PHP_REDIS_API int redis_zadd_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_zrandmember_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_zdiff_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_set_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); -PHP_REDIS_API int redis_read_geosearch_response(zval *zdst, RedisSock *redis_sock, long long elements, int with_aux_data);
View file
redis-6.2.0.tgz/redis-6.2.0/php_redis.h
Deleted
@@ -1,69 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Original author: Alfonso Jimenez <yo@alfonsojimenez.com> | - | Maintainer: Nicolas Favre-Felix <n.favre-felix@owlient.eu> | - | Maintainer: Michael Grunder <michael.grunder@gmail.com> | - | Maintainer: Nasreddine Bouafif <n.bouafif@owlient.eu> | - +----------------------------------------------------------------------+ -*/ - -#include "common.h" - -#ifndef PHP_REDIS_H -#define PHP_REDIS_H - -/* phpredis version */ -#define PHP_REDIS_VERSION "6.2.0" - -/* For convenience we store the salt as a printable hex string which requires 2 - * characters per byte + 1 for the NULL terminator */ -#define REDIS_SALT_BYTES 32 -#define REDIS_SALT_SIZE ((2 * REDIS_SALT_BYTES) + 1) - -ZEND_BEGIN_MODULE_GLOBALS(redis) - char saltREDIS_SALT_SIZE; -ZEND_END_MODULE_GLOBALS(redis) - -ZEND_EXTERN_MODULE_GLOBALS(redis) -#define REDIS_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(redis, v) - -#ifdef ZTS -#include "TSRM.h" -#endif - -PHP_MINIT_FUNCTION(redis); -PHP_MSHUTDOWN_FUNCTION(redis); -PHP_MINFO_FUNCTION(redis); - -PHP_REDIS_API int redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent); - -PHP_REDIS_API int redis_response_enqueued(RedisSock *redis_sock); - -PHP_REDIS_API int redis_sock_read_multibulk_multi_reply_loop( - INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab); - -extern zend_module_entry redis_module_entry; - -#define redis_module_ptr &redis_module_entry -#define phpext_redis_ptr redis_module_ptr - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */
View file
redis-6.2.0.tgz/redis-6.2.0/redis.c
Deleted
@@ -1,3053 +0,0 @@ -/* -*- Mode: C; tab-width: 4 -*- */ -/* - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Original author: Alfonso Jimenez <yo@alfonsojimenez.com> | - | Maintainer: Nicolas Favre-Felix <n.favre-felix@owlient.eu> | - | Maintainer: Nasreddine Bouafif <n.bouafif@owlient.eu> | - | Maintainer: Michael Grunder <michael.grunder@gmail.com> | - +----------------------------------------------------------------------+ -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php_redis.h" -#include "redis_array.h" -#include "redis_cluster.h" -#include "redis_commands.h" -#include "redis_sentinel.h" -#include <ext/spl/spl_exceptions.h> -#include <zend_exceptions.h> -#include <ext/standard/info.h> -#include <ext/hash/php_hash.h> - -#if PHP_VERSION_ID < 80400 -#include <ext/standard/php_random.h> -#else -#include <ext/random/php_random.h> -#endif - -#ifdef PHP_SESSION -#include <ext/session/php_session.h> -#endif - -#include "library.h" - -#ifdef HAVE_REDIS_ZSTD -#include <zstd.h> -#endif - -#ifdef HAVE_REDIS_LZ4 -#include <lz4.h> -#endif - -#ifdef PHP_SESSION -extern ps_module ps_mod_redis; -extern ps_module ps_mod_redis_cluster; -#endif - -zend_class_entry *redis_ce; -zend_class_entry *redis_exception_ce; - -#if PHP_VERSION_ID < 80000 -#include "redis_legacy_arginfo.h" -#else -#include "zend_attributes.h" -#include "redis_arginfo.h" -#endif - -extern const zend_function_entry *redis_get_methods(void) -{ - return class_Redis_methods; -} - -extern int le_cluster_slot_cache; -int le_redis_pconnect; - -PHP_INI_BEGIN() - /* redis arrays */ - PHP_INI_ENTRY("redis.arrays.algorithm", "", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.arrays.auth", "", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.arrays.autorehash", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.arrays.connecttimeout", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.arrays.distributor", "", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.arrays.functions", "", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.arrays.hosts", "", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.arrays.index", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.arrays.lazyconnect", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.arrays.names", "", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.arrays.pconnect", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.arrays.previous", "", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.arrays.readtimeout", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.arrays.retryinterval", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.arrays.consistent", "0", PHP_INI_ALL, NULL) - - /* redis cluster */ - PHP_INI_ENTRY("redis.clusters.cache_slots", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.clusters.auth", "", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.clusters.persistent", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.clusters.read_timeout", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.clusters.seeds", "", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.clusters.timeout", "0", PHP_INI_ALL, NULL) - - /* redis pconnect */ - PHP_INI_ENTRY("redis.pconnect.pooling_enabled", "1", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.pconnect.connection_limit", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.pconnect.echo_check_liveness", "1", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.pconnect.pool_detect_dirty", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.pconnect.pool_poll_timeout", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.pconnect.pool_pattern", "", PHP_INI_ALL, NULL) - - /* redis session */ - PHP_INI_ENTRY("redis.session.locking_enabled", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.session.lock_expire", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.session.lock_retries", "100", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.session.lock_wait_time", "20000", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.session.early_refresh", "0", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.session.compression", "none", PHP_INI_ALL, NULL) - PHP_INI_ENTRY("redis.session.compression_level", "3", PHP_INI_ALL, NULL) -PHP_INI_END() - -static const zend_module_dep redis_deps = { -#ifdef HAVE_REDIS_IGBINARY - ZEND_MOD_REQUIRED("igbinary") -#endif -#ifdef HAVE_REDIS_MSGPACK - ZEND_MOD_REQUIRED("msgpack") -#endif -#ifdef HAVE_REDIS_JSON - ZEND_MOD_REQUIRED("json") -#endif -#ifdef PHP_SESSION - ZEND_MOD_REQUIRED("session") -#endif - ZEND_MOD_END -}; - -ZEND_DECLARE_MODULE_GLOBALS(redis) - -zend_module_entry redis_module_entry = { - STANDARD_MODULE_HEADER_EX, - NULL, - redis_deps, - "redis", - NULL, - PHP_MINIT(redis), - NULL, - NULL, - NULL, - PHP_MINFO(redis), - PHP_REDIS_VERSION, - PHP_MODULE_GLOBALS(redis), - NULL, - NULL, - NULL, - STANDARD_MODULE_PROPERTIES_EX -}; - -#ifdef COMPILE_DL_REDIS -ZEND_GET_MODULE(redis) -#endif - -zend_object_handlers redis_object_handlers; - -/* Send a static DISCARD in case we're in MULTI mode. */ -static int -redis_send_discard(RedisSock *redis_sock) -{ - char *resp; - int resp_len, result = FAILURE; - - /* send our DISCARD command */ - if (redis_sock_write(redis_sock, ZEND_STRL(RESP_DISCARD_CMD)) >= 0 && - (resp = redis_sock_read(redis_sock,&resp_len)) != NULL) - { - /* success if we get OK */ - result = (resp_len == 3 && redis_strncmp(resp, ZEND_STRL("+OK")) == 0) ? SUCCESS:FAILURE; - - /* free our response */ - efree(resp); - } - - /* return success/failure */ - return result; -} - -/* Passthru for destroying cluster cache */ -static void cluster_cache_dtor(zend_resource *rsrc) { - if (rsrc->ptr) { - cluster_cache_free(rsrc->ptr); - } -} - -void -free_redis_object(zend_object *object) -{ - redis_object *redis = PHPREDIS_GET_OBJECT(redis_object, object); - - zend_object_std_dtor(&redis->std);
View file
redis-6.2.0.tgz/redis-6.2.0/redis.stub.php
Deleted
@@ -1,4730 +0,0 @@ -<?php - -/** - * @generate-function-entries - * @generate-legacy-arginfo - * @generate-class-entries - */ - -class Redis { - /** - * - * @var int - * @cvalue REDIS_NOT_FOUND - * - */ - public const REDIS_NOT_FOUND = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_STRING - * - */ - public const REDIS_STRING = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_SET - * - */ - public const REDIS_SET = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_LIST - * - */ - public const REDIS_LIST = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_ZSET - * - */ - public const REDIS_ZSET = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_HASH - * - */ - public const REDIS_HASH = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_STREAM - * - */ - public const REDIS_STREAM = UNKNOWN; - - /** - * - * @var int - * @cvalue ATOMIC - * - */ - public const ATOMIC = UNKNOWN; - - /** - * - * @var int - * @cvalue MULTI - * - */ - public const MULTI = UNKNOWN; - - /** - * - * @var int - * @cvalue PIPELINE - * - */ - public const PIPELINE = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_OPT_SERIALIZER - * - */ - public const OPT_SERIALIZER = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_OPT_PREFIX - * - */ - public const OPT_PREFIX = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_OPT_READ_TIMEOUT - * - */ - public const OPT_READ_TIMEOUT = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_OPT_TCP_KEEPALIVE - * - */ - public const OPT_TCP_KEEPALIVE = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_OPT_COMPRESSION - * - */ - public const OPT_COMPRESSION = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_OPT_REPLY_LITERAL - * - */ - public const OPT_REPLY_LITERAL = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_OPT_COMPRESSION_LEVEL - * - */ - public const OPT_COMPRESSION_LEVEL = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_OPT_NULL_MBULK_AS_NULL - * - */ - public const OPT_NULL_MULTIBULK_AS_NULL = UNKNOWN; - - /** - * @var int - * @cvalue REDIS_OPT_PACK_IGNORE_NUMBERS - * - * When enabled, this option tells PhpRedis to ignore purely numeric values - * when packing and unpacking data. This does not include numeric strings. - * If you want numeric strings to be ignored, typecast them to an int or float. - * - * The primary purpose of this option is to make it more ergonomic when - * setting keys that will later be incremented or decremented. - * - * Note: This option incurs a small performance penalty when reading data - * because we have to see if the data is a string representation of an int - * or float. - * - * @example - * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY); - * $redis->setOption(Redis::OPT_PACK_IGNORE_NUMBERS, true); - * - * $redis->set('answer', 32); - * - * var_dump($redis->incrBy('answer', 10)); // int(42) - * var_dump($redis->get('answer')); // int(42) - */ - public const OPT_PACK_IGNORE_NUMBERS = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_SERIALIZER_NONE - * - */ - public const SERIALIZER_NONE = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_SERIALIZER_PHP - * - */ - public const SERIALIZER_PHP = UNKNOWN; - -#ifdef HAVE_REDIS_IGBINARY - /** - * - * @var int
View file
redis-6.2.0.tgz/redis-6.2.0/redis_arginfo.h
Deleted
@@ -1,2089 +0,0 @@ -/* This is a generated file, edit the .stub.php file instead. - * Stub hash: 805a66c17b7c9972c73a979bdd67f98f7c1f6c74 */ - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___destruct, 0, 0, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis__compress, 0, 1, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis__uncompress arginfo_class_Redis__compress - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis__prefix, 0, 1, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis__serialize, 0, 1, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis__unserialize, 0, 1, IS_MIXED, 0) - ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis__pack arginfo_class_Redis__serialize - -#define arginfo_class_Redis__unpack arginfo_class_Redis__unserialize - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_acl, 0, 1, IS_MIXED, 0) - ZEND_ARG_TYPE_INFO(0, subcmd, IS_STRING, 0) - ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_append, 0, 2, Redis, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_auth, 0, 1, Redis, MAY_BE_BOOL) - ZEND_ARG_TYPE_INFO(0, credentials, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_bgSave, 0, 0, Redis, MAY_BE_BOOL) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_bgrewriteaof arginfo_class_Redis_bgSave - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_waitaof, 0, 3, Redis, MAY_BE_ARRAY|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, numlocal, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, numreplicas, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_bitcount, 0, 1, Redis, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, start, IS_LONG, 0, "0") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, end, IS_LONG, 0, "-1") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, bybit, _IS_BOOL, 0, "false") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_bitop, 0, 3, Redis, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, operation, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, deskey, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, srckey, IS_STRING, 0) - ZEND_ARG_VARIADIC_TYPE_INFO(0, other_keys, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_bitpos, 0, 2, Redis, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, bit, _IS_BOOL, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, start, IS_LONG, 0, "0") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, end, IS_LONG, 0, "-1") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, bybit, _IS_BOOL, 0, "false") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_blPop, 0, 2, Redis, MAY_BE_ARRAY|MAY_BE_NULL|MAY_BE_FALSE) - ZEND_ARG_TYPE_MASK(0, key_or_keys, MAY_BE_STRING|MAY_BE_ARRAY, NULL) - ZEND_ARG_TYPE_MASK(0, timeout_or_key, MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_LONG, NULL) - ZEND_ARG_VARIADIC_TYPE_INFO(0, extra_args, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_brPop arginfo_class_Redis_blPop - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_brpoplpush, 0, 3, Redis, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, src, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, dst, IS_STRING, 0) - ZEND_ARG_TYPE_MASK(0, timeout, MAY_BE_LONG|MAY_BE_DOUBLE, NULL) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_bzPopMax, 0, 2, Redis, MAY_BE_ARRAY|MAY_BE_FALSE) - ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, NULL) - ZEND_ARG_TYPE_MASK(0, timeout_or_key, MAY_BE_STRING|MAY_BE_LONG, NULL) - ZEND_ARG_VARIADIC_TYPE_INFO(0, extra_args, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_bzPopMin arginfo_class_Redis_bzPopMax - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_bzmpop, 0, 3, Redis, MAY_BE_ARRAY|MAY_BE_NULL|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0) - ZEND_ARG_TYPE_INFO(0, keys, IS_ARRAY, 0) - ZEND_ARG_TYPE_INFO(0, from, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, count, IS_LONG, 0, "1") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_zmpop, 0, 2, Redis, MAY_BE_ARRAY|MAY_BE_NULL|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, keys, IS_ARRAY, 0) - ZEND_ARG_TYPE_INFO(0, from, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, count, IS_LONG, 0, "1") -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_blmpop arginfo_class_Redis_bzmpop - -#define arginfo_class_Redis_lmpop arginfo_class_Redis_zmpop - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_clearLastError, 0, 0, _IS_BOOL, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_client, 0, 1, IS_MIXED, 0) - ZEND_ARG_TYPE_INFO(0, opt, IS_STRING, 0) - ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_close arginfo_class_Redis_clearLastError - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_command, 0, 0, IS_MIXED, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, opt, IS_STRING, 1, "null") - ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_config, 0, 1, IS_MIXED, 0) - ZEND_ARG_TYPE_INFO(0, operation, IS_STRING, 0) - ZEND_ARG_TYPE_MASK(0, key_or_settings, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, value, IS_STRING, 1, "null") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_connect, 0, 1, _IS_BOOL, 0) - ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 0, "6379") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_DOUBLE, 0, "0") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, persistent_id, IS_STRING, 1, "null") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retry_interval, IS_LONG, 0, "0") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, read_timeout, IS_DOUBLE, 0, "0") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, context, IS_ARRAY, 1, "null") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_copy, 0, 2, Redis, MAY_BE_BOOL) - ZEND_ARG_TYPE_INFO(0, src, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, dst, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_dbSize, 0, 0, Redis, MAY_BE_LONG|MAY_BE_FALSE) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_debug, 0, 1, Redis, MAY_BE_STRING) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_decr, 0, 1, Redis, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, by, IS_LONG, 0, "1") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_decrBy, 0, 2, Redis, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, value, IS_LONG, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_del, 0, 1, Redis, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_TYPE_MASK(0, key, MAY_BE_ARRAY|MAY_BE_STRING, NULL) - ZEND_ARG_VARIADIC_TYPE_INFO(0, other_keys, IS_STRING, 0) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_delete arginfo_class_Redis_del - -#define arginfo_class_Redis_discard arginfo_class_Redis_bgSave - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_dump, 0, 1, Redis, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_echo, 0, 1, Redis, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_eval, 0, 1, IS_MIXED, 0) - ZEND_ARG_TYPE_INFO(0, script, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, args, IS_ARRAY, 0, "") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, num_keys, IS_LONG, 0, "0") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_eval_ro, 0, 1, IS_MIXED, 0) - ZEND_ARG_TYPE_INFO(0, script_sha, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, args, IS_ARRAY, 0, "") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, num_keys, IS_LONG, 0, "0")
View file
redis-6.2.0.tgz/redis-6.2.0/redis_array.c
Deleted
@@ -1,1295 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Nicolas Favre-Felix <n.favre-felix@owlient.eu> | - | Maintainer: Michael Grunder <michael.grunder@gmail.com> | - +----------------------------------------------------------------------+ -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "common.h" -#include "library.h" -#include "redis_array.h" -#include "redis_array_impl.h" - -#include <ext/standard/info.h> -#include <zend_exceptions.h> - -/* Simple macro to detect failure in a RedisArray call */ -#define RA_CALL_FAILED(rv, cmd) ( \ - (Z_TYPE_P(rv) == IS_FALSE) || \ - (Z_TYPE_P(rv) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_P(rv)) == 0) || \ - (Z_TYPE_P(rv) == IS_LONG && Z_LVAL_P(rv) == 0 && !strcasecmp(cmd, "TYPE")) \ -) - -extern zend_class_entry *redis_ce; -zend_class_entry *redis_array_ce; - -#if PHP_VERSION_ID < 80000 -#include "redis_array_legacy_arginfo.h" -#else -#include "zend_attributes.h" -#include "redis_array_arginfo.h" -#endif - -PHP_MINIT_FUNCTION(redis_array) -{ - /* RedisSentinel class */ - redis_array_ce = register_class_RedisArray(); - redis_array_ce->create_object = create_redis_array_object; - - return SUCCESS; -} - -static void -redis_array_free(RedisArray *ra) -{ - int i; - - /* continuum */ - if (ra->continuum) { - efree(ra->continuum->points); - efree(ra->continuum); - } - - /* Redis objects */ - for(i = 0; i< ra->count; i++) { - zval_dtor(&ra->redisi); - zend_string_release(ra->hostsi); - } - efree(ra->redis); - efree(ra->hosts); - - /* delete hash function */ - zval_dtor(&ra->z_fun); - - /* Distributor */ - zval_dtor(&ra->z_dist); - - /* Hashing algorithm */ - if (ra->algorithm) zend_string_release(ra->algorithm); - - /* Delete pur commands */ - zend_hash_destroy(ra->pure_cmds); - FREE_HASHTABLE(ra->pure_cmds); - - /* Free structure itself */ - efree(ra); -} - -typedef struct { - RedisArray *ra; - zend_object std; -} redis_array_object; - -zend_object_handlers redis_array_object_handlers; - -void -free_redis_array_object(zend_object *object) -{ - redis_array_object *obj = PHPREDIS_GET_OBJECT(redis_array_object, object); - - if (obj->ra) { - if (obj->ra->prev) redis_array_free(obj->ra->prev); - redis_array_free(obj->ra); - } - zend_object_std_dtor(&obj->std); -} - -zend_object * -create_redis_array_object(zend_class_entry *ce) -{ - redis_array_object *obj = ecalloc(1, sizeof(redis_array_object) + zend_object_properties_size(ce)); - - obj->ra = NULL; - - zend_object_std_init(&obj->std, ce); - object_properties_init(&obj->std, ce); - - memcpy(&redis_array_object_handlers, zend_get_std_object_handlers(), sizeof(redis_array_object_handlers)); - redis_array_object_handlers.offset = XtOffsetOf(redis_array_object, std); - redis_array_object_handlers.free_obj = free_redis_array_object; - obj->std.handlers = &redis_array_object_handlers; - - return &obj->std; -} - -/** - * redis_array_get - */ -PHP_REDIS_API RedisArray * -redis_array_get(zval *id) -{ - redis_array_object *obj; - - if (Z_TYPE_P(id) == IS_OBJECT) { - obj = PHPREDIS_ZVAL_GET_OBJECT(redis_array_object, id); - return obj->ra; - } - return NULL; -} - -/* {{{ proto RedisArray RedisArray::__construct() - Public constructor */ -PHP_METHOD(RedisArray, __construct) -{ - zval *z0, z_fun, z_dist, *zpData, *z_opts = NULL; - RedisArray *ra = NULL; - zend_bool b_index = 0, b_autorehash = 0, b_pconnect = 0, consistent = 0; - HashTable *hPrev = NULL, *hOpts = NULL; - zend_long l_retry_interval = 0; - zend_bool b_lazy_connect = 0; - double d_connect_timeout = 0, read_timeout = 0.0; - zend_string *algorithm = NULL, *user = NULL, *pass = NULL; - redis_array_object *obj; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|a", &z0, &z_opts) == FAILURE) { - RETURN_FALSE; - } - - /* Bail if z0 isn't a string or an array. - * Note: WRONG_PARAM_COUNT seems wrong but this is what we have been doing - * for ages so we can't really change it until the next major version. - */ - if (Z_TYPE_P(z0) != IS_ARRAY && Z_TYPE_P(z0) != IS_STRING) { -#if PHP_VERSION_ID < 80000 - WRONG_PARAM_COUNT; -#else - zend_argument_type_error(1, "must be of type string|array, %s given", zend_zval_type_name(z0)); - RETURN_THROWS(); -#endif - } - - /* If it's a string we want to load the array from ini information */ - if (Z_TYPE_P(z0) == IS_STRING) { - ra = ra_load_array(Z_STRVAL_P(z0)); - goto finish; - } - - ZVAL_NULL(&z_fun); - ZVAL_NULL(&z_dist); - - /* extract options */ - if(z_opts) { - hOpts = Z_ARRVAL_P(z_opts); - - /* extract previous ring. */ - zpData = REDIS_HASH_STR_FIND_STATIC(hOpts, "previous"); - if (zpData && Z_TYPE_P(zpData) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_P(zpData)) > 0) { - hPrev = Z_ARRVAL_P(zpData); - } - - - REDIS_CONF_AUTH_STATIC(hOpts, "auth", &user, &pass); - REDIS_CONF_ZVAL_STATIC(hOpts, "function", &z_fun, 1, 0); - REDIS_CONF_ZVAL_STATIC(hOpts, "distributor", &z_dist, 1, 0); - REDIS_CONF_STRING_STATIC(hOpts, "algorithm", &algorithm); - REDIS_CONF_ZEND_BOOL_STATIC(hOpts, "index", &b_index);
View file
redis-6.2.0.tgz/redis-6.2.0/redis_array_impl.c
Deleted
@@ -1,1221 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Nicolas Favre-Felix <n.favre-felix@owlient.eu> | - | Maintainer: Michael Grunder <michael.grunder@gmail.com> | - +----------------------------------------------------------------------+ -*/ -#include "redis_array_impl.h" -#include "php_redis.h" -#include "library.h" - -#include "php_variables.h" -#include "SAPI.h" -#include "ext/standard/url.h" -#include "ext/standard/crc32.h" -#include "ext/standard/md5.h" - -#include "ext/hash/php_hash.h" - -#define PHPREDIS_INDEX_NAME "__phpredis_array_index__" - -extern zend_class_entry *redis_ce; - -static RedisArray * -ra_load_hosts(RedisArray *ra, HashTable *hosts, zend_string *user, - zend_string *pass, long retry_interval, zend_bool b_lazy_connect) -{ - int i = 0, host_len; - char *host, *p; - short port; - zval *zpData; - redis_object *redis; - - /* init connections */ - ZEND_HASH_FOREACH_VAL(hosts, zpData) { - if (Z_TYPE_P(zpData) != IS_STRING) { - return NULL; - } - - /* default values */ - host = Z_STRVAL_P(zpData); - host_len = Z_STRLEN_P(zpData); - ra->hostsi = zend_string_init(host, host_len, 0); - port = 6379; - - if((p = strrchr(host, ':'))) { /* found port */ - host_len = p - host; - port = (short)atoi(p+1); - } else if(strchr(host,'/') != NULL) { /* unix socket */ - port = -1; - } - - /* create Redis object */ - object_init_ex(&ra->redisi, redis_ce); - redis = PHPREDIS_ZVAL_GET_OBJECT(redis_object, &ra->redisi); - - /* create socket */ - redis->sock = redis_sock_create(host, host_len, port, ra->connect_timeout, - ra->read_timeout, ra->pconnect, NULL, - retry_interval); - - redis_sock_set_auth(redis->sock, user, pass); - - if (!b_lazy_connect) { - if (redis_sock_server_open(redis->sock) < 0) { - ra->count = ++i; - return NULL; - } - } - - ra->count = ++i; - } ZEND_HASH_FOREACH_END(); - - return ra; -} - -/* List pure functions */ -void -ra_init_function_table(RedisArray *ra) -{ - ALLOC_HASHTABLE(ra->pure_cmds); - zend_hash_init(ra->pure_cmds, 0, NULL, NULL, 0); - - #define ra_add_pure_cmd(cmd) \ - zend_hash_str_update_ptr(ra->pure_cmds, cmd, sizeof(cmd) - 1, NULL); - - ra_add_pure_cmd("EXISTS"); - ra_add_pure_cmd("GET"); - ra_add_pure_cmd("GETBIT"); - ra_add_pure_cmd("GETRANGE"); - ra_add_pure_cmd("HEXISTS"); - ra_add_pure_cmd("HGET"); - ra_add_pure_cmd("HGETALL"); - ra_add_pure_cmd("HKEYS"); - ra_add_pure_cmd("HLEN"); - ra_add_pure_cmd("HMGET"); - ra_add_pure_cmd("HVALS"); - ra_add_pure_cmd("LINDEX"); - ra_add_pure_cmd("LLEN"); - ra_add_pure_cmd("LRANGE"); - ra_add_pure_cmd("OBJECT"); - ra_add_pure_cmd("SCARD"); - ra_add_pure_cmd("SDIFF"); - ra_add_pure_cmd("SINTER"); - ra_add_pure_cmd("SISMEMBER"); - ra_add_pure_cmd("SMEMBERS"); - ra_add_pure_cmd("SRANDMEMBER"); - ra_add_pure_cmd("STRLEN"); - ra_add_pure_cmd("SUNION"); - ra_add_pure_cmd("TYPE"); - ra_add_pure_cmd("ZCARD"); - ra_add_pure_cmd("ZCOUNT"); - ra_add_pure_cmd("ZRANGE"); - ra_add_pure_cmd("ZRANK"); - ra_add_pure_cmd("ZREVRANGE"); - ra_add_pure_cmd("ZREVRANGEBYSCORE"); - ra_add_pure_cmd("ZREVRANK"); - ra_add_pure_cmd("ZSCORE"); - - #undef ra_add_pure_cmd -} - -static int -ra_find_name(const char *name) { - - const char *ini_names, *p, *next; - /* php_printf("Loading redis array with name=%s\n", name); */ - - ini_names = INI_STR("redis.arrays.names"); - for(p = ini_names; p;) { - next = strchr(p, ','); - if(next) { - if(redis_strncmp(p, name, next - p) == 0) { - return 1; - } - } else { - if(strcmp(p, name) == 0) { - return 1; - } - break; - } - p = next + 1; - } - - return 0; -} - -/* load array from INI settings */ -RedisArray *ra_load_array(const char *name) { - zval *z_data, z_tmp, z_fun, z_dist; - zval z_params_hosts; - zval z_params_prev; - RedisArray *ra = NULL; - - zend_string *algorithm = NULL, *user = NULL, *pass = NULL; - zend_bool b_index = 0, b_autorehash = 0, b_pconnect = 0, consistent = 0; - zend_long l_retry_interval = 0; - zend_bool b_lazy_connect = 0; - double d_connect_timeout = 0, read_timeout = 0.0; - HashTable *hHosts = NULL, *hPrev = NULL; - size_t name_len = strlen(name); - char *iptr; - - /* find entry */ - if(!ra_find_name(name)) - return ra; - - ZVAL_NULL(&z_fun); - ZVAL_NULL(&z_dist); - - /* find hosts */ - array_init(&z_params_hosts); - if ((iptr = INI_STR("redis.arrays.hosts")) != NULL) { - sapi_module.treat_data(PARSE_STRING, estrdup(iptr), &z_params_hosts); - if ((z_data = zend_hash_str_find(Z_ARRVAL(z_params_hosts), name, name_len)) != NULL) { - hHosts = Z_ARRVAL_P(z_data); - } - } - - /* find previous hosts */ - array_init(&z_params_prev); - if ((iptr = INI_STR("redis.arrays.previous")) != NULL) { - sapi_module.treat_data(PARSE_STRING, estrdup(iptr), &z_params_prev); - if ((z_data = zend_hash_str_find(Z_ARRVAL(z_params_prev), name, name_len)) != NULL) { - if (Z_TYPE_P(z_data) == IS_ARRAY) { - hPrev = Z_ARRVAL_P(z_data); - } - } - } -
View file
redis-6.2.0.tgz/redis-6.2.0/redis_cluster.c
Deleted
@@ -1,3198 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Michael Grunder <michael.grunder@gmail.com> | - | Maintainer: Nicolas Favre-Felix <n.favre-felix@owlient.eu> | - +----------------------------------------------------------------------+ -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "common.h" -#include "php_redis.h" -#include "ext/standard/info.h" -#include "crc16.h" -#include "redis_cluster.h" -#include "redis_commands.h" -#include <ext/spl/spl_exceptions.h> -#include <zend_exceptions.h> -#include "library.h" -#include <php_variables.h> -#include <SAPI.h> - -zend_class_entry *redis_cluster_ce; - -/* Exception handler */ -zend_class_entry *redis_cluster_exception_ce; - -#if PHP_VERSION_ID < 80000 -#include "redis_cluster_legacy_arginfo.h" -#else -#include "zend_attributes.h" -#include "redis_cluster_arginfo.h" -#endif - -PHP_MINIT_FUNCTION(redis_cluster) -{ - redis_cluster_ce = register_class_RedisCluster(); - redis_cluster_ce->create_object = create_cluster_context; - - redis_cluster_exception_ce = register_class_RedisClusterException(spl_ce_RuntimeException); - - return SUCCESS; -} - -/* Handlers for RedisCluster */ -zend_object_handlers RedisCluster_handlers; - -/* Our context seeds will be a hash table with RedisSock* pointers */ -static void ht_free_seed(zval *data) { - RedisSock *redis_sock = *(RedisSock**)data; - if (redis_sock) redis_free_socket(redis_sock); -} - -/* Free redisClusterNode objects we've stored */ -static void ht_free_node(zval *data) { - redisClusterNode *node = *(redisClusterNode**)data; - cluster_free_node(node); -} - -/* Create redisCluster context */ -zend_object * create_cluster_context(zend_class_entry *class_type) { - redisCluster *cluster; - - // Allocate our actual struct - cluster = ecalloc(1, sizeof(redisCluster) + zend_object_properties_size(class_type)); - - // We're not currently subscribed anywhere - cluster->subscribed_slot = -1; - - // Allocate our RedisSock we'll use to store prefix/serialization flags - cluster->flags = ecalloc(1, sizeof(RedisSock)); - - // Allocate our hash table for seeds - ALLOC_HASHTABLE(cluster->seeds); - zend_hash_init(cluster->seeds, 0, NULL, ht_free_seed, 0); - - // Allocate our hash table for connected Redis objects - ALLOC_HASHTABLE(cluster->nodes); - zend_hash_init(cluster->nodes, 0, NULL, ht_free_node, 0); - - // Initialize it - zend_object_std_init(&cluster->std, class_type); - - object_properties_init(&cluster->std, class_type); - memcpy(&RedisCluster_handlers, zend_get_std_object_handlers(), sizeof(RedisCluster_handlers)); - RedisCluster_handlers.offset = XtOffsetOf(redisCluster, std); - RedisCluster_handlers.free_obj = free_cluster_context; - - cluster->std.handlers = &RedisCluster_handlers; - - return &cluster->std; -} - -/* Free redisCluster context */ -void free_cluster_context(zend_object *object) { - redisCluster *cluster = PHPREDIS_GET_OBJECT(redisCluster, object); - - cluster_free(cluster, 0); - zend_object_std_dtor(&cluster->std); -} - -/* Take user provided seeds and return unique and valid ones */ -/* Attempt to connect to a Redis cluster provided seeds and timeout options */ -static void redis_cluster_init(redisCluster *c, HashTable *ht_seeds, double timeout, - double read_timeout, int persistent, zend_string *user, - zend_string *pass, zval *context) -{ - zend_string *hash = NULL, **seeds; - redisCachedCluster *cc; - uint32_t nseeds; - char *err; - - /* Validate our arguments and get a sanitized seed array */ - seeds = cluster_validate_args(timeout, read_timeout, ht_seeds, &nseeds, &err); - if (seeds == NULL) { - CLUSTER_THROW_EXCEPTION(err, 0); - return; - } - - if (user && ZSTR_LEN(user)) - c->flags->user = zend_string_copy(user); - if (pass && ZSTR_LEN(pass)) - c->flags->pass = zend_string_copy(pass); - if (context) { - redis_sock_set_stream_context(c->flags, context); - } - - c->flags->timeout = timeout; - c->flags->read_timeout = read_timeout; - c->flags->persistent = persistent; - c->waitms = (long)(1000 * (timeout + read_timeout)); - - /* Attempt to load slots from cache if caching is enabled */ - if (CLUSTER_CACHING_ENABLED()) { - /* Exit early if we can load from cache */ - hash = cluster_hash_seeds(seeds, nseeds); - if ((cc = cluster_cache_load(hash))) { - cluster_init_cache(c, cc); - goto cleanup; - } - } - - /* Initialize seeds and attempt to map keyspace */ - cluster_init_seeds(c, seeds, nseeds); - if (cluster_map_keyspace(c) == SUCCESS && hash) - cluster_cache_store(hash, c->nodes); - -cleanup: - if (hash) zend_string_release(hash); - free_seed_array(seeds, nseeds); -} - - -/* Attempt to load a named cluster configured in php.ini */ -void redis_cluster_load(redisCluster *c, char *name, int name_len) { - zval z_seeds, z_tmp, *z_value; - zend_string *user = NULL, *pass = NULL; - double timeout = 0, read_timeout = 0; - int persistent = 0; - char *iptr; - HashTable *ht_seeds = NULL; - - /* Seeds */ - array_init(&z_seeds); - if ((iptr = INI_STR("redis.clusters.seeds")) != NULL) { - sapi_module.treat_data(PARSE_STRING, estrdup(iptr), &z_seeds); - } - if ((z_value = zend_hash_str_find(Z_ARRVAL(z_seeds), name, name_len)) != NULL) { - ht_seeds = Z_ARRVAL_P(z_value); - } else { - zval_dtor(&z_seeds); - CLUSTER_THROW_EXCEPTION("Couldn't find seeds for cluster", 0); - return; - } - - /* Connection timeout */ - if ((iptr = INI_STR("redis.clusters.timeout")) != NULL) { - array_init(&z_tmp); - sapi_module.treat_data(PARSE_STRING, estrdup(iptr), &z_tmp); - redis_conf_double(Z_ARRVAL(z_tmp), name, name_len, &timeout); - zval_dtor(&z_tmp); - } - - /* Read timeout */ - if ((iptr = INI_STR("redis.clusters.read_timeout")) != NULL) { - array_init(&z_tmp); - sapi_module.treat_data(PARSE_STRING, estrdup(iptr), &z_tmp); - redis_conf_double(Z_ARRVAL(z_tmp), name, name_len, &read_timeout);
View file
redis-6.2.0.tgz/redis-6.2.0/redis_cluster.h
Deleted
@@ -1,101 +0,0 @@ -#ifndef REDIS_CLUSTER_H -#define REDIS_CLUSTER_H - -#include "cluster_library.h" -#include <php.h> -#include <stddef.h> - -/* Get attached object context */ -#define GET_CONTEXT() PHPREDIS_ZVAL_GET_OBJECT(redisCluster, getThis()) - -/* Command building/processing is identical for every command */ -#define CLUSTER_BUILD_CMD(name, c, cmd, cmd_len, slot) \ - redis_##name##_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, c->flags, &cmd, \ - &cmd_len, &slot) - -/* Append information required to handle MULTI commands to the tail of our MULTI - * linked list. */ -#define CLUSTER_ENQUEUE_RESPONSE(c, slot, cb, ctx) \ - clusterFoldItem *_item; \ - _item = emalloc(sizeof(clusterFoldItem)); \ - _item->callback = cb; \ - _item->slot = slot; \ - _item->ctx = ctx; \ - _item->next = NULL; \ - _item->flags = c->flags->flags; \ - if(c->multi_head == NULL) { \ - c->multi_head = _item; \ - c->multi_curr = _item; \ - } else { \ - c->multi_curr->next = _item; \ - c->multi_curr = _item; \ - } \ - -/* Simple macro to free our enqueued callbacks after we EXEC */ -#define CLUSTER_FREE_QUEUE(c) \ - clusterFoldItem *_item = c->multi_head, *_tmp; \ - while(_item) { \ - _tmp = _item->next; \ - efree(_item); \ - _item = _tmp; \ - } \ - c->multi_head = c->multi_curr = NULL; \ - -/* Reset anything flagged as MULTI */ -#define CLUSTER_RESET_MULTI(c) \ - redisClusterNode *_node; \ - ZEND_HASH_FOREACH_PTR(c->nodes, _node) { \ - if (_node == NULL) break; \ - _node->sock->watching = 0; \ - _node->sock->mode = ATOMIC; \ - } ZEND_HASH_FOREACH_END(); \ - c->flags->watching = 0; \ - c->flags->mode = ATOMIC; \ - -/* Simple 1-1 command -> response macro */ -#define CLUSTER_PROCESS_CMD(cmdname, resp_func, readcmd) \ - redisCluster *c = GET_CONTEXT(); \ - c->readonly = CLUSTER_IS_ATOMIC(c) && readcmd; \ - char *cmd; int cmd_len; short slot; void *ctx=NULL; \ - if(redis_##cmdname##_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU,c->flags, &cmd, \ - &cmd_len, &slot, &ctx)==FAILURE) { \ - RETURN_FALSE; \ - } \ - if(cluster_send_command(c,slot,cmd,cmd_len)<0 || c->err!=NULL) {\ - efree(cmd); \ - RETURN_FALSE; \ - } \ - efree(cmd); \ - if(c->flags->mode == MULTI) { \ - CLUSTER_ENQUEUE_RESPONSE(c, slot, resp_func, ctx); \ - RETURN_ZVAL(getThis(), 1, 0); \ - } \ - resp_func(INTERNAL_FUNCTION_PARAM_PASSTHRU, c, ctx); - -/* More generic processing, where only the keyword differs */ -#define CLUSTER_PROCESS_KW_CMD(kw, cmdfunc, resp_func, readcmd) \ - redisCluster *c = GET_CONTEXT(); \ - c->readonly = CLUSTER_IS_ATOMIC(c) && readcmd; \ - char *cmd; int cmd_len; short slot; void *ctx=NULL; \ - if(cmdfunc(INTERNAL_FUNCTION_PARAM_PASSTHRU, c->flags, kw, &cmd, &cmd_len,\ - &slot,&ctx)==FAILURE) { \ - RETURN_FALSE; \ - } \ - if(cluster_send_command(c,slot,cmd,cmd_len)<0 || c->err!=NULL) { \ - efree(cmd); \ - RETURN_FALSE; \ - } \ - efree(cmd); \ - if(c->flags->mode == MULTI) { \ - CLUSTER_ENQUEUE_RESPONSE(c, slot, resp_func, ctx); \ - RETURN_ZVAL(getThis(), 1, 0); \ - } \ - resp_func(INTERNAL_FUNCTION_PARAM_PASSTHRU, c, ctx); - -extern zend_class_entry *redis_cluster_ce; -extern zend_class_entry *redis_cluster_exception_ce; -extern PHP_MINIT_FUNCTION(redis_cluster); -extern zend_object * create_cluster_context(zend_class_entry *class_type); -extern void free_cluster_context(zend_object *object); - -#endif
View file
redis-6.2.0.tgz/redis-6.2.0/redis_cluster.stub.php
Deleted
@@ -1,1220 +0,0 @@ -<?php - -/** - * @generate-function-entries - * @generate-legacy-arginfo - * @generate-class-entries - */ - -class RedisCluster { - /** - * - * @var int - * @cvalue REDIS_OPT_FAILOVER - * - */ - public const OPT_SLAVE_FAILOVER = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_FAILOVER_NONE - * - */ - public const FAILOVER_NONE = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_FAILOVER_ERROR - * - */ - public const FAILOVER_ERROR = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_FAILOVER_DISTRIBUTE - * - */ - public const FAILOVER_DISTRIBUTE = UNKNOWN; - - /** - * - * @var int - * @cvalue REDIS_FAILOVER_DISTRIBUTE_SLAVES - * - */ - public const FAILOVER_DISTRIBUTE_SLAVES = UNKNOWN; - - public function __construct(string|null $name, ?array $seeds = null, int|float $timeout = 0, int|float $read_timeout = 0, bool $persistent = false, #\SensitiveParameter mixed $auth = null, ?array $context = null); - - /** - * @see Redis::_compress() - */ - public function _compress(string $value): string; - - /** - * @see Redis::_uncompress() - */ - public function _uncompress(string $value): string; - - /** - * @see Redis::_serialize() - */ - public function _serialize(mixed $value): bool|string; - - /** - * @see Redis::_unserialize() - */ - public function _unserialize(string $value): mixed; - - /** - * @see Redis::_pack() - */ - public function _pack(mixed $value): string; - - /** - * @see Redis::_unpack() - */ - public function _unpack(string $value): mixed; - - /** - * @see Redis::_prefix() - */ - public function _prefix(string $key): bool|string; - - public function _masters(): array; - - public function _redir(): string|null; - - /** - * @see Redis::acl - */ - public function acl(string|array $key_or_address, string $subcmd, string ...$args): mixed; - - /** - * @see Redis::append() - */ - public function append(string $key, mixed $value): RedisCluster|bool|int; - - /** - * @see Redis::bgrewriteaof - */ - public function bgrewriteaof(string|array $key_or_address): RedisCluster|bool; - - public function waitaof(string|array $key_or_address, int $numlocal, - int $numreplicas, int $timeout): RedisCluster|array|false; - - /** - * @see Redis::bgsave - */ - public function bgsave(string|array $key_or_address): RedisCluster|bool; - - /** - * @see Redis::bitcount - */ - public function bitcount(string $key, int $start = 0, int $end = -1, bool $bybit = false): RedisCluster|bool|int; - - /** - * @see Redis::bitop - */ - public function bitop(string $operation, string $deskey, string $srckey, string ...$otherkeys): RedisCluster|bool|int; - - /** - * Return the position of the first bit set to 0 or 1 in a string. - * - * @see https://https://redis.io/commands/bitpos/ - * - * @param string $key The key to check (must be a string) - * @param bool $bit Whether to look for an unset (0) or set (1) bit. - * @param int $start Where in the string to start looking. - * @param int $end Where in the string to stop looking. - * @param bool $bybit If true, Redis will treat $start and $end as BIT values and not bytes, so if start - * was 0 and end was 2, Redis would only search the first two bits. - */ - public function bitpos(string $key, bool $bit, int $start = 0, int $end = -1, bool $bybit = false): RedisCluster|int|false; - - /** - * See Redis::blpop() - */ - public function blpop(string|array $key, string|float|int $timeout_or_key, mixed ...$extra_args): RedisCluster|array|null|false; - - /** - * See Redis::brpop() - */ - public function brpop(string|array $key, string|float|int $timeout_or_key, mixed ...$extra_args): RedisCluster|array|null|false; - - /** - * See Redis::brpoplpush() - */ - public function brpoplpush(string $srckey, string $deskey, int $timeout): mixed; - - /** - * Move an element from one list into another. - * - * @see Redis::lmove - */ - public function lmove(string $src, string $dst, string $wherefrom, string $whereto): Redis|string|false; - - /** - * Move an element from one list to another, blocking up to a timeout until an element is available. - * - * @see Redis::blmove - * - */ - public function blmove(string $src, string $dst, string $wherefrom, string $whereto, float $timeout): Redis|string|false; - - /** - * @see Redis::bzpopmax - */ - public function bzpopmax(string|array $key, string|int $timeout_or_key, mixed ...$extra_args): array; - - /** - * @see Redis::bzpopmin - */ - public function bzpopmin(string|array $key, string|int $timeout_or_key, mixed ...$extra_args): array; - - /** - * @see Redis::bzmpop - */ - public function bzmpop(float $timeout, array $keys, string $from, int $count = 1): RedisCluster|array|null|false; - - /** - * @see Redis::zmpop - */ - public function zmpop(array $keys, string $from, int $count = 1): RedisCluster|array|null|false; - - /** - * @see Redis::blmpop() - */ - public function blmpop(float $timeout, array $keys, string $from, int $count = 1): RedisCluster|array|null|false; - - /** - * @see Redis::lmpop() - */ - public function lmpop(array $keys, string $from, int $count = 1): RedisCluster|array|null|false; - - /** - * @see Redis::clearlasterror()
View file
redis-6.2.0.tgz/redis-6.2.0/redis_cluster_arginfo.h
Deleted
@@ -1,1588 +0,0 @@ -/* This is a generated file, edit the .stub.php file instead. - * Stub hash: 43a43fa735ced4b48a361078ac8a10fb62cb1244 */ - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1) - ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 1) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, seeds, IS_ARRAY, 1, "null") - ZEND_ARG_TYPE_MASK(0, timeout, MAY_BE_LONG|MAY_BE_DOUBLE, "0") - ZEND_ARG_TYPE_MASK(0, read_timeout, MAY_BE_LONG|MAY_BE_DOUBLE, "0") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, persistent, _IS_BOOL, 0, "false") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, auth, IS_MIXED, 0, "null") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, context, IS_ARRAY, 1, "null") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster__compress, 0, 1, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster__uncompress arginfo_class_RedisCluster__compress - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_RedisCluster__serialize, 0, 1, MAY_BE_BOOL|MAY_BE_STRING) - ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster__unserialize, 0, 1, IS_MIXED, 0) - ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster__pack, 0, 1, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster__unpack arginfo_class_RedisCluster__unserialize - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_RedisCluster__prefix, 0, 1, MAY_BE_BOOL|MAY_BE_STRING) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster__masters, 0, 0, IS_ARRAY, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster__redir, 0, 0, IS_STRING, 1) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_acl, 0, 2, IS_MIXED, 0) - ZEND_ARG_TYPE_MASK(0, key_or_address, MAY_BE_STRING|MAY_BE_ARRAY, NULL) - ZEND_ARG_TYPE_INFO(0, subcmd, IS_STRING, 0) - ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_append, 0, 2, RedisCluster, MAY_BE_BOOL|MAY_BE_LONG) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_bgrewriteaof, 0, 1, RedisCluster, MAY_BE_BOOL) - ZEND_ARG_TYPE_MASK(0, key_or_address, MAY_BE_STRING|MAY_BE_ARRAY, NULL) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_waitaof, 0, 4, RedisCluster, MAY_BE_ARRAY|MAY_BE_FALSE) - ZEND_ARG_TYPE_MASK(0, key_or_address, MAY_BE_STRING|MAY_BE_ARRAY, NULL) - ZEND_ARG_TYPE_INFO(0, numlocal, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, numreplicas, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster_bgsave arginfo_class_RedisCluster_bgrewriteaof - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_bitcount, 0, 1, RedisCluster, MAY_BE_BOOL|MAY_BE_LONG) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, start, IS_LONG, 0, "0") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, end, IS_LONG, 0, "-1") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, bybit, _IS_BOOL, 0, "false") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_bitop, 0, 3, RedisCluster, MAY_BE_BOOL|MAY_BE_LONG) - ZEND_ARG_TYPE_INFO(0, operation, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, deskey, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, srckey, IS_STRING, 0) - ZEND_ARG_VARIADIC_TYPE_INFO(0, otherkeys, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_bitpos, 0, 2, RedisCluster, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, bit, _IS_BOOL, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, start, IS_LONG, 0, "0") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, end, IS_LONG, 0, "-1") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, bybit, _IS_BOOL, 0, "false") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_blpop, 0, 2, RedisCluster, MAY_BE_ARRAY|MAY_BE_NULL|MAY_BE_FALSE) - ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, NULL) - ZEND_ARG_TYPE_MASK(0, timeout_or_key, MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_LONG, NULL) - ZEND_ARG_VARIADIC_TYPE_INFO(0, extra_args, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster_brpop arginfo_class_RedisCluster_blpop - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_brpoplpush, 0, 3, IS_MIXED, 0) - ZEND_ARG_TYPE_INFO(0, srckey, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, deskey, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_lmove, 0, 4, Redis, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, src, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, dst, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, wherefrom, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, whereto, IS_STRING, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_blmove, 0, 5, Redis, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, src, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, dst, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, wherefrom, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, whereto, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_bzpopmax, 0, 2, IS_ARRAY, 0) - ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, NULL) - ZEND_ARG_TYPE_MASK(0, timeout_or_key, MAY_BE_STRING|MAY_BE_LONG, NULL) - ZEND_ARG_VARIADIC_TYPE_INFO(0, extra_args, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster_bzpopmin arginfo_class_RedisCluster_bzpopmax - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_bzmpop, 0, 3, RedisCluster, MAY_BE_ARRAY|MAY_BE_NULL|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0) - ZEND_ARG_TYPE_INFO(0, keys, IS_ARRAY, 0) - ZEND_ARG_TYPE_INFO(0, from, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, count, IS_LONG, 0, "1") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_zmpop, 0, 2, RedisCluster, MAY_BE_ARRAY|MAY_BE_NULL|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, keys, IS_ARRAY, 0) - ZEND_ARG_TYPE_INFO(0, from, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, count, IS_LONG, 0, "1") -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster_blmpop arginfo_class_RedisCluster_bzmpop - -#define arginfo_class_RedisCluster_lmpop arginfo_class_RedisCluster_zmpop - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_clearlasterror, 0, 0, _IS_BOOL, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_RedisCluster_client, 0, 2, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_BOOL) - ZEND_ARG_TYPE_MASK(0, key_or_address, MAY_BE_STRING|MAY_BE_ARRAY, NULL) - ZEND_ARG_TYPE_INFO(0, subcommand, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, arg, IS_STRING, 1, "null") -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster_close arginfo_class_RedisCluster_clearlasterror - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_cluster, 0, 2, IS_MIXED, 0) - ZEND_ARG_TYPE_MASK(0, key_or_address, MAY_BE_STRING|MAY_BE_ARRAY, NULL) - ZEND_ARG_TYPE_INFO(0, command, IS_STRING, 0) - ZEND_ARG_VARIADIC_TYPE_INFO(0, extra_args, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_command, 0, 0, IS_MIXED, 0) - ZEND_ARG_VARIADIC_TYPE_INFO(0, extra_args, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_config, 0, 2, IS_MIXED, 0) - ZEND_ARG_TYPE_MASK(0, key_or_address, MAY_BE_STRING|MAY_BE_ARRAY, NULL) - ZEND_ARG_TYPE_INFO(0, subcommand, IS_STRING, 0) - ZEND_ARG_VARIADIC_TYPE_INFO(0, extra_args, IS_MIXED, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_dbsize, 0, 1, RedisCluster, MAY_BE_LONG) - ZEND_ARG_TYPE_MASK(0, key_or_address, MAY_BE_STRING|MAY_BE_ARRAY, NULL) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_copy, 0, 2, RedisCluster, MAY_BE_BOOL) - ZEND_ARG_TYPE_INFO(0, src, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, dst, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_decr, 0, 1, RedisCluster, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, by, IS_LONG, 0, "1") -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_decrby, 0, 2, RedisCluster, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, value, IS_LONG, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_decrbyfloat, 0, 2, IS_DOUBLE, 0) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, value, IS_DOUBLE, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_del, 0, 1, RedisCluster, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_TYPE_MASK(0, key, MAY_BE_ARRAY|MAY_BE_STRING, NULL) - ZEND_ARG_VARIADIC_TYPE_INFO(0, other_keys, IS_STRING, 0) -ZEND_END_ARG_INFO()
View file
redis-6.2.0.tgz/redis-6.2.0/redis_cluster_legacy_arginfo.h
Deleted
@@ -1,1423 +0,0 @@ -/* This is a generated file, edit the .stub.php file instead. - * Stub hash: 43a43fa735ced4b48a361078ac8a10fb62cb1244 */ - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1) - ZEND_ARG_INFO(0, name) - ZEND_ARG_INFO(0, seeds) - ZEND_ARG_INFO(0, timeout) - ZEND_ARG_INFO(0, read_timeout) - ZEND_ARG_INFO(0, persistent) - ZEND_ARG_INFO(0, auth) - ZEND_ARG_INFO(0, context) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster__compress, 0, 0, 1) - ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster__uncompress arginfo_class_RedisCluster__compress - -#define arginfo_class_RedisCluster__serialize arginfo_class_RedisCluster__compress - -#define arginfo_class_RedisCluster__unserialize arginfo_class_RedisCluster__compress - -#define arginfo_class_RedisCluster__pack arginfo_class_RedisCluster__compress - -#define arginfo_class_RedisCluster__unpack arginfo_class_RedisCluster__compress - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster__prefix, 0, 0, 1) - ZEND_ARG_INFO(0, key) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster__masters, 0, 0, 0) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster__redir arginfo_class_RedisCluster__masters - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_acl, 0, 0, 2) - ZEND_ARG_INFO(0, key_or_address) - ZEND_ARG_INFO(0, subcmd) - ZEND_ARG_VARIADIC_INFO(0, args) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_append, 0, 0, 2) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_bgrewriteaof, 0, 0, 1) - ZEND_ARG_INFO(0, key_or_address) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_waitaof, 0, 0, 4) - ZEND_ARG_INFO(0, key_or_address) - ZEND_ARG_INFO(0, numlocal) - ZEND_ARG_INFO(0, numreplicas) - ZEND_ARG_INFO(0, timeout) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster_bgsave arginfo_class_RedisCluster_bgrewriteaof - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_bitcount, 0, 0, 1) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, start) - ZEND_ARG_INFO(0, end) - ZEND_ARG_INFO(0, bybit) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_bitop, 0, 0, 3) - ZEND_ARG_INFO(0, operation) - ZEND_ARG_INFO(0, deskey) - ZEND_ARG_INFO(0, srckey) - ZEND_ARG_VARIADIC_INFO(0, otherkeys) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_bitpos, 0, 0, 2) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, bit) - ZEND_ARG_INFO(0, start) - ZEND_ARG_INFO(0, end) - ZEND_ARG_INFO(0, bybit) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_blpop, 0, 0, 2) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, timeout_or_key) - ZEND_ARG_VARIADIC_INFO(0, extra_args) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster_brpop arginfo_class_RedisCluster_blpop - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_brpoplpush, 0, 0, 3) - ZEND_ARG_INFO(0, srckey) - ZEND_ARG_INFO(0, deskey) - ZEND_ARG_INFO(0, timeout) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_lmove, 0, 0, 4) - ZEND_ARG_INFO(0, src) - ZEND_ARG_INFO(0, dst) - ZEND_ARG_INFO(0, wherefrom) - ZEND_ARG_INFO(0, whereto) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_blmove, 0, 0, 5) - ZEND_ARG_INFO(0, src) - ZEND_ARG_INFO(0, dst) - ZEND_ARG_INFO(0, wherefrom) - ZEND_ARG_INFO(0, whereto) - ZEND_ARG_INFO(0, timeout) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster_bzpopmax arginfo_class_RedisCluster_blpop - -#define arginfo_class_RedisCluster_bzpopmin arginfo_class_RedisCluster_blpop - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_bzmpop, 0, 0, 3) - ZEND_ARG_INFO(0, timeout) - ZEND_ARG_INFO(0, keys) - ZEND_ARG_INFO(0, from) - ZEND_ARG_INFO(0, count) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_zmpop, 0, 0, 2) - ZEND_ARG_INFO(0, keys) - ZEND_ARG_INFO(0, from) - ZEND_ARG_INFO(0, count) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster_blmpop arginfo_class_RedisCluster_bzmpop - -#define arginfo_class_RedisCluster_lmpop arginfo_class_RedisCluster_zmpop - -#define arginfo_class_RedisCluster_clearlasterror arginfo_class_RedisCluster__masters - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_client, 0, 0, 2) - ZEND_ARG_INFO(0, key_or_address) - ZEND_ARG_INFO(0, subcommand) - ZEND_ARG_INFO(0, arg) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster_close arginfo_class_RedisCluster__masters - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_cluster, 0, 0, 2) - ZEND_ARG_INFO(0, key_or_address) - ZEND_ARG_INFO(0, command) - ZEND_ARG_VARIADIC_INFO(0, extra_args) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_command, 0, 0, 0) - ZEND_ARG_VARIADIC_INFO(0, extra_args) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_config, 0, 0, 2) - ZEND_ARG_INFO(0, key_or_address) - ZEND_ARG_INFO(0, subcommand) - ZEND_ARG_VARIADIC_INFO(0, extra_args) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster_dbsize arginfo_class_RedisCluster_bgrewriteaof - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_copy, 0, 0, 2) - ZEND_ARG_INFO(0, src) - ZEND_ARG_INFO(0, dst) - ZEND_ARG_INFO(0, options) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_decr, 0, 0, 1) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, by) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster_decrby arginfo_class_RedisCluster_append - -#define arginfo_class_RedisCluster_decrbyfloat arginfo_class_RedisCluster_append - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_del, 0, 0, 1) - ZEND_ARG_INFO(0, key) - ZEND_ARG_VARIADIC_INFO(0, other_keys) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster_discard arginfo_class_RedisCluster__masters - -#define arginfo_class_RedisCluster_dump arginfo_class_RedisCluster__prefix - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_echo, 0, 0, 2) - ZEND_ARG_INFO(0, key_or_address) - ZEND_ARG_INFO(0, msg) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_eval, 0, 0, 1) - ZEND_ARG_INFO(0, script) - ZEND_ARG_INFO(0, args) - ZEND_ARG_INFO(0, num_keys) -ZEND_END_ARG_INFO() - -#define arginfo_class_RedisCluster_eval_ro arginfo_class_RedisCluster_eval - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_evalsha, 0, 0, 1) - ZEND_ARG_INFO(0, script_sha)
View file
redis-6.2.0.tgz/redis-6.2.0/redis_commands.c
Deleted
@@ -1,6472 +0,0 @@ -/* -*- Mode: C; tab-width: 4 -*- */ -/* - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Original Author: Michael Grunder <michael.grunder@gmail.com | - | Maintainer: Nicolas Favre-Felix <n.favre-felix@owlient.eu> | - +----------------------------------------------------------------------+ -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "redis_commands.h" - -#include "php_network.h" - -#ifndef PHP_WIN32 -#include <netinet/tcp.h> /* TCP_KEEPALIVE */ -#else -#include <winsock.h> -#endif - -#include <zend_exceptions.h> - -/* Georadius sort type */ -typedef enum geoSortType { - SORT_NONE, - SORT_ASC, - SORT_DESC -} geoSortType; - -/* Georadius store type */ -typedef enum geoStoreType { - STORE_NONE, - STORE_COORD, - STORE_DIST -} geoStoreType; - -/* Georadius options structure */ -typedef struct geoOptions { - int withcoord; - int withdist; - int withhash; - long count; - zend_bool any; - geoSortType sort; - geoStoreType store; - zend_string *key; -} geoOptions; - -typedef struct redisLcsOptions { - zend_bool len; - zend_bool idx; - zend_long minmatchlen; - zend_bool withmatchlen; -} redisLcsOptions; - -typedef struct redisRestoreOptions { - zend_bool replace; - zend_bool absttl; - zend_long idletime; - zend_long freq; -} redisRestoreOptions; - -#define REDIS_ZCMD_HAS_DST_KEY (1 << 0) -#define REDIS_ZCMD_HAS_WITHSCORES (1 << 1) -#define REDIS_ZCMD_HAS_BY_LEX_SCORE (1 << 2) -#define REDIS_ZCMD_HAS_REV (1 << 3) -#define REDIS_ZCMD_HAS_LIMIT (1 << 4) -#define REDIS_ZCMD_INT_RANGE (1 << 5) -#define REDIS_ZCMD_HAS_AGGREGATE (1 << 6) - -/* ZRANGE, ZRANGEBYSCORE, ZRANGESTORE options */ -typedef struct redisZcmdOptions { - zend_bool withscores; - zend_bool byscore; - zend_bool bylex; - zend_bool rev; - zend_string *aggregate; - struct { - zend_bool enabled; - zend_long offset; - zend_long count; - } limit; -} redisZcmdOptions; - -/* Local passthrough macro for command construction. Given that these methods - * are generic (so they work whether the caller is Redis or RedisCluster) we - * will always have redis_sock, slot*, and */ -#define REDIS_CMD_SPPRINTF(ret, kw, fmt, ...) \ - redis_spprintf(redis_sock, slot, ret, kw, fmt, ##__VA_ARGS__) - -/* Generic commands based on method signature and what kind of things we're - * processing. Lots of Redis commands take something like key, value, or - * key, value long. Each unique signature like this is written only once */ - -/* A command that takes no arguments */ -int redis_empty_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, - void **ctx) -{ - *cmd_len = REDIS_CMD_SPPRINTF(cmd, kw, ""); - return SUCCESS; -} - -/* Helper to construct a raw command. Given that the cluster and non cluster - * versions are different (RedisCluster needs an additional argument to direct - * the command) we take the start of our array and count */ -int redis_build_raw_cmd(zval *z_args, int argc, char **cmd, int *cmd_len) -{ - smart_string cmdstr = {0}; - int i; - - /* Make sure our first argument is a string */ - if (Z_TYPE(z_args0) != IS_STRING) { - php_error_docref(NULL, E_WARNING, - "When sending a 'raw' command, the first argument must be a string!"); - return FAILURE; - } - - /* Initialize our command string */ - redis_cmd_init_sstr(&cmdstr, argc-1, Z_STRVAL(z_args0), Z_STRLEN(z_args0)); - - for (i = 1; i < argc; i++) { - switch (Z_TYPE(z_argsi)) { - case IS_STRING: - redis_cmd_append_sstr(&cmdstr, Z_STRVAL(z_argsi), - Z_STRLEN(z_argsi)); - break; - case IS_LONG: - redis_cmd_append_sstr_long(&cmdstr,Z_LVAL(z_argsi)); - break; - case IS_DOUBLE: - redis_cmd_append_sstr_dbl(&cmdstr,Z_DVAL(z_argsi)); - break; - default: - php_error_docref(NULL, E_WARNING, - "Raw command arguments must be scalar values!"); - efree(cmdstr.c); - return FAILURE; - } - } - - /* Push command and length to caller */ - *cmd = cmdstr.c; - *cmd_len = cmdstr.len; - - return SUCCESS; -} - -smart_string * -redis_build_script_cmd(smart_string *cmd, int argc, zval *z_args) -{ - int i; - zend_string *zstr; - - if (Z_TYPE(z_args0) != IS_STRING) { - return NULL; - } - // Branch based on the directive - if (zend_string_equals_literal_ci(Z_STR(z_args0), "kill")) { - // Simple SCRIPT_KILL command - REDIS_CMD_INIT_SSTR_STATIC(cmd, argc, "SCRIPT"); - redis_cmd_append_sstr(cmd, ZEND_STRL("KILL")); - } else if (zend_string_equals_literal_ci(Z_STR(z_args0), "flush")) { - // Simple SCRIPT FLUSH ASYNC | SYNC - if (argc > 1 && ( - Z_TYPE(z_args1) != IS_STRING || ( - !zend_string_equals_literal_ci(Z_STR(z_args1), "sync") && - !zend_string_equals_literal_ci(Z_STR(z_args1), "async") - ) - )) { - return NULL; - } - REDIS_CMD_INIT_SSTR_STATIC(cmd, argc, "SCRIPT"); - redis_cmd_append_sstr(cmd, ZEND_STRL("FLUSH")); - if (argc > 1) { - redis_cmd_append_sstr(cmd, Z_STRVAL(z_args1), Z_STRLEN(z_args1)); - } - } else if (zend_string_equals_literal_ci(Z_STR(z_args0), "load")) { - // Make sure we have a second argument, and it's not empty. If it is - // empty, we can just return an empty array (which is what Redis does) - if (argc < 2 || Z_TYPE(z_args1) != IS_STRING || Z_STRLEN(z_args1) < 1) { - return NULL; - } - // Format our SCRIPT LOAD command - REDIS_CMD_INIT_SSTR_STATIC(cmd, argc, "SCRIPT"); - redis_cmd_append_sstr(cmd, ZEND_STRL("LOAD")); - redis_cmd_append_sstr(cmd, Z_STRVAL(z_args1), Z_STRLEN(z_args1));
View file
redis-6.2.0.tgz/redis-6.2.0/redis_commands.h
Deleted
@@ -1,408 +0,0 @@ -#ifndef REDIS_COMMANDS_H -#define REDIS_COMMANDS_H - -#include "common.h" -#include "library.h" -#include "cluster_library.h" - -/* Pick a random slot, any slot (for stuff like publish/subscribe) */ -#define CMD_RAND_SLOT(slot) \ - if(slot) *slot = rand() % REDIS_CLUSTER_MOD - -/* Macro for setting the slot if we've been asked to */ -#define CMD_SET_SLOT(slot,key,key_len) \ - if (slot) *slot = cluster_hash_key(key,key_len); - -/* Simple container so we can push subscribe context out */ -typedef struct { - zend_fcall_info fci; - zend_fcall_info_cache fci_cache; -} subscribeCallback; - -typedef struct subscribeContext { - char *kw; - int argc; - subscribeCallback cb; -} subscribeContext; - -/* Construct a raw command */ -int redis_build_raw_cmd(zval *z_args, int argc, char **cmd, int *cmd_len); - -/* Construct a script command */ -smart_string *redis_build_script_cmd(smart_string *cmd, int argc, zval *z_args); - -/* Redis command generics. Many commands share common prototypes meaning that - * we can write one function to handle all of them. For example, there are - * many COMMAND key value commands, or COMMAND key commands. */ - -int redis_replicaof_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, - void **ctx); - -int redis_empty_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_opt_str_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, char *kw, - char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_str_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_key_long_val_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_key_long_str_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_kv_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_key_str_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_key_key_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_key_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_key_long_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_long_long_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_key_long_long_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_key_str_str_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_key_dbl_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_key_varval_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_key_val_arr_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_key_str_arr_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_pop_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_blocking_pop_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -/* Construct SCAN and similar commands, as well as check iterator */ -int redis_scan_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - REDIS_SCAN_TYPE type, char **cmd, int *cmd_len); - -/* ZRANGE, ZREVRANGE, ZRANGEBYSCORE, and ZREVRANGEBYSCORE callback type */ -typedef int (*zrange_cb)(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *,char**,int*,int*,short*,void**); - -int redis_zrange_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_config_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_function_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_zrandmember_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_zdiff_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_zinterunion_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_zdiffstore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_zinterunionstore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_intercard_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, - void **ctx); - -int redis_slowlog_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_lcs_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_mpop_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, char *kw, - char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_restore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_pubsub_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_unsubscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_zrangebylex_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_gen_zlex_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_eval_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_fcall_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_failover_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_flush_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_xrange_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_georadius_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_georadiusbymember_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_geosearch_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_geosearchstore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx); - -/* Commands which need a unique construction mechanism. This is either because - * they don't share a signature with any other command, or because there is - * specific processing we do (e.g. verifying subarguments) that make them - * unique */ - -int redis_waitaof_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx); - -int redis_info_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, - char **cmd, int *cmd_len, short *slot, void **ctx); -
View file
redis-6.2.0.tgz/redis-6.2.0/redis_legacy_arginfo.h
Deleted
@@ -1,1920 +0,0 @@ -/* This is a generated file, edit the .stub.php file instead. - * Stub hash: 805a66c17b7c9972c73a979bdd67f98f7c1f6c74 */ - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0) - ZEND_ARG_INFO(0, options) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___destruct, 0, 0, 0) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis__compress, 0, 0, 1) - ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis__uncompress arginfo_class_Redis__compress - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis__prefix, 0, 0, 1) - ZEND_ARG_INFO(0, key) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis__serialize arginfo_class_Redis__compress - -#define arginfo_class_Redis__unserialize arginfo_class_Redis__compress - -#define arginfo_class_Redis__pack arginfo_class_Redis__compress - -#define arginfo_class_Redis__unpack arginfo_class_Redis__compress - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_acl, 0, 0, 1) - ZEND_ARG_INFO(0, subcmd) - ZEND_ARG_VARIADIC_INFO(0, args) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_append, 0, 0, 2) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_auth, 0, 0, 1) - ZEND_ARG_INFO(0, credentials) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_bgSave arginfo_class_Redis___destruct - -#define arginfo_class_Redis_bgrewriteaof arginfo_class_Redis___destruct - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_waitaof, 0, 0, 3) - ZEND_ARG_INFO(0, numlocal) - ZEND_ARG_INFO(0, numreplicas) - ZEND_ARG_INFO(0, timeout) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_bitcount, 0, 0, 1) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, start) - ZEND_ARG_INFO(0, end) - ZEND_ARG_INFO(0, bybit) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_bitop, 0, 0, 3) - ZEND_ARG_INFO(0, operation) - ZEND_ARG_INFO(0, deskey) - ZEND_ARG_INFO(0, srckey) - ZEND_ARG_VARIADIC_INFO(0, other_keys) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_bitpos, 0, 0, 2) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, bit) - ZEND_ARG_INFO(0, start) - ZEND_ARG_INFO(0, end) - ZEND_ARG_INFO(0, bybit) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_blPop, 0, 0, 2) - ZEND_ARG_INFO(0, key_or_keys) - ZEND_ARG_INFO(0, timeout_or_key) - ZEND_ARG_VARIADIC_INFO(0, extra_args) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_brPop arginfo_class_Redis_blPop - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_brpoplpush, 0, 0, 3) - ZEND_ARG_INFO(0, src) - ZEND_ARG_INFO(0, dst) - ZEND_ARG_INFO(0, timeout) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_bzPopMax, 0, 0, 2) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, timeout_or_key) - ZEND_ARG_VARIADIC_INFO(0, extra_args) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_bzPopMin arginfo_class_Redis_bzPopMax - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_bzmpop, 0, 0, 3) - ZEND_ARG_INFO(0, timeout) - ZEND_ARG_INFO(0, keys) - ZEND_ARG_INFO(0, from) - ZEND_ARG_INFO(0, count) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_zmpop, 0, 0, 2) - ZEND_ARG_INFO(0, keys) - ZEND_ARG_INFO(0, from) - ZEND_ARG_INFO(0, count) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_blmpop arginfo_class_Redis_bzmpop - -#define arginfo_class_Redis_lmpop arginfo_class_Redis_zmpop - -#define arginfo_class_Redis_clearLastError arginfo_class_Redis___destruct - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_client, 0, 0, 1) - ZEND_ARG_INFO(0, opt) - ZEND_ARG_VARIADIC_INFO(0, args) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_close arginfo_class_Redis___destruct - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_command, 0, 0, 0) - ZEND_ARG_INFO(0, opt) - ZEND_ARG_VARIADIC_INFO(0, args) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_config, 0, 0, 1) - ZEND_ARG_INFO(0, operation) - ZEND_ARG_INFO(0, key_or_settings) - ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_connect, 0, 0, 1) - ZEND_ARG_INFO(0, host) - ZEND_ARG_INFO(0, port) - ZEND_ARG_INFO(0, timeout) - ZEND_ARG_INFO(0, persistent_id) - ZEND_ARG_INFO(0, retry_interval) - ZEND_ARG_INFO(0, read_timeout) - ZEND_ARG_INFO(0, context) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_copy, 0, 0, 2) - ZEND_ARG_INFO(0, src) - ZEND_ARG_INFO(0, dst) - ZEND_ARG_INFO(0, options) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_dbSize arginfo_class_Redis___destruct - -#define arginfo_class_Redis_debug arginfo_class_Redis__prefix - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_decr, 0, 0, 1) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, by) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_decrBy arginfo_class_Redis_append - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_del, 0, 0, 1) - ZEND_ARG_INFO(0, key) - ZEND_ARG_VARIADIC_INFO(0, other_keys) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_delete arginfo_class_Redis_del - -#define arginfo_class_Redis_discard arginfo_class_Redis___destruct - -#define arginfo_class_Redis_dump arginfo_class_Redis__prefix - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_echo, 0, 0, 1) - ZEND_ARG_INFO(0, str) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_eval, 0, 0, 1) - ZEND_ARG_INFO(0, script) - ZEND_ARG_INFO(0, args) - ZEND_ARG_INFO(0, num_keys) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_eval_ro, 0, 0, 1) - ZEND_ARG_INFO(0, script_sha) - ZEND_ARG_INFO(0, args) - ZEND_ARG_INFO(0, num_keys) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_evalsha, 0, 0, 1) - ZEND_ARG_INFO(0, sha1) - ZEND_ARG_INFO(0, args) - ZEND_ARG_INFO(0, num_keys) -ZEND_END_ARG_INFO() - -#define arginfo_class_Redis_evalsha_ro arginfo_class_Redis_evalsha - -#define arginfo_class_Redis_exec arginfo_class_Redis___destruct - -#define arginfo_class_Redis_exists arginfo_class_Redis_del -
View file
redis-6.2.0.tgz/redis-6.2.0/redis_session.c
Deleted
@@ -1,1383 +0,0 @@ -/* -*- Mode: C; tab-width: 4 -*- */ -/* - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Original author: Alfonso Jimenez <yo@alfonsojimenez.com> | - | Maintainer: Nicolas Favre-Felix <n.favre-felix@owlient.eu> | - | Maintainer: Nasreddine Bouafif <n.bouafif@owlient.eu> | - | Maintainer: Michael Grunder <michael.grunder@gmail.com> | - +----------------------------------------------------------------------+ -*/ - -#include "common.h" - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef PHP_SESSION -#include "ext/standard/info.h" -#include "php_redis.h" -#include "redis_session.h" -#include <zend_exceptions.h> - -#include "library.h" -#include "cluster_library.h" - -#include "php.h" -#include "php_ini.h" -#include "php_variables.h" -#include "SAPI.h" -#include "ext/standard/url.h" - -#define REDIS_SESSION_PREFIX "PHPREDIS_SESSION:" -#define CLUSTER_SESSION_PREFIX "PHPREDIS_CLUSTER_SESSION:" - -/* Session lock LUA as well as its SHA1 hash */ -#define LOCK_RELEASE_LUA_STR "if redis.call(\"get\",KEYS1) == ARGV1 then return redis.call(\"del\",KEYS1) else return 0 end" -#define LOCK_RELEASE_LUA_LEN (sizeof(LOCK_RELEASE_LUA_STR) - 1) -#define LOCK_RELEASE_SHA_STR "b70c2384248f88e6b75b9f89241a180f856ad852" -#define LOCK_RELEASE_SHA_LEN (sizeof(LOCK_RELEASE_SHA_STR) - 1) - -/* Check if a response is the Redis +OK status response */ -#define IS_REDIS_OK(r, len) (r != NULL && len == 3 && !memcmp(r, "+OK", 3)) -#define NEGATIVE_LOCK_RESPONSE 1 - -#define CLUSTER_DEFAULT_PREFIX() \ - zend_string_init(CLUSTER_SESSION_PREFIX, sizeof(CLUSTER_SESSION_PREFIX) - 1, 0) - -ps_module ps_mod_redis = { - PS_MOD_UPDATE_TIMESTAMP(redis) -}; - -ps_module ps_mod_redis_cluster = { - PS_MOD_UPDATE_TIMESTAMP(rediscluster) -}; - -typedef struct { - zend_bool is_locked; - zend_string *session_key; - zend_string *lock_key; - zend_string *lock_secret; -} redis_session_lock_status; - -typedef struct redis_pool_member_ { - - RedisSock *redis_sock; - int weight; - struct redis_pool_member_ *next; - -} redis_pool_member; - -typedef struct { - - int totalWeight; - int count; - - redis_pool_member *head; - redis_session_lock_status lock_status; - -} redis_pool; - -// static char *session_conf_string(HashTable *ht, const char *key, size_t keylen) { -// } - -PHP_REDIS_API void -redis_pool_add(redis_pool *pool, RedisSock *redis_sock, int weight) -{ - redis_pool_member *rpm = ecalloc(1, sizeof(redis_pool_member)); - rpm->redis_sock = redis_sock; - rpm->weight = weight; - - rpm->next = pool->head; - pool->head = rpm; - - pool->totalWeight += weight; -} - -PHP_REDIS_API void -redis_pool_free(redis_pool *pool) { - - redis_pool_member *rpm, *next; - - if (pool == NULL) - return; - - rpm = pool->head; - while (rpm) { - next = rpm->next; - redis_sock_disconnect(rpm->redis_sock, 0, 1); - redis_free_socket(rpm->redis_sock); - efree(rpm); - rpm = next; - } - - /* Cleanup after our lock */ - if (pool->lock_status.session_key) zend_string_release(pool->lock_status.session_key); - if (pool->lock_status.lock_secret) zend_string_release(pool->lock_status.lock_secret); - if (pool->lock_status.lock_key) zend_string_release(pool->lock_status.lock_key); - - /* Cleanup pool itself */ - efree(pool); -} - -/* Retrieve session.gc_maxlifetime from php.ini protecting against an integer overflow */ -static int session_gc_maxlifetime(void) { - zend_long value = INI_INT("session.gc_maxlifetime"); - if (value > INT_MAX) { - php_error_docref(NULL, E_NOTICE, "session.gc_maxlifetime overflows INT_MAX, truncating."); - return INT_MAX; - } else if (value <= 0) { - php_error_docref(NULL, E_NOTICE, "session.gc_maxlifetime is <= 0, defaulting to 1440 seconds"); - return 1440; - } - - return value; -} - -/* Retrieve redis.session.compression from php.ini */ -static int session_compression_type(void) { - const char *compression = INI_STR("redis.session.compression"); - if(compression == NULL || *compression == '\0' || strncasecmp(compression, "none", sizeof("none") - 1) == 0) { - return REDIS_COMPRESSION_NONE; - } - -#ifdef HAVE_REDIS_LZF - if(strncasecmp(compression, "lzf", sizeof("lzf") - 1) == 0) { - return REDIS_COMPRESSION_LZF; - } -#endif -#ifdef HAVE_REDIS_ZSTD - if(strncasecmp(compression, "zstd", sizeof("zstd") - 1) == 0) { - return REDIS_COMPRESSION_ZSTD; - } -#endif -#ifdef HAVE_REDIS_LZ4 - if(strncasecmp(compression, "lz4", sizeof("lz4") - 1) == 0) { - return REDIS_COMPRESSION_LZ4; - } -#endif - - // E_NOTICE when outside of valid values - php_error_docref(NULL, E_NOTICE, "redis.session.compression is outside of valid values, disabling"); - - return REDIS_COMPRESSION_NONE; -} - -/* Helper to compress session data */ -static int -session_compress_data(RedisSock *redis_sock, char *data, size_t len, - char **compressed_data, size_t *compressed_len) -{ - if (redis_sock->compression) { - if(redis_compress(redis_sock, compressed_data, compressed_len, data, len)) { - return 1; - } - } - - *compressed_data = data; - *compressed_len = len; - - return 0; -} - -/* Helper to uncompress session data */ -static int -session_uncompress_data(RedisSock *redis_sock, char *data, size_t len, - char **decompressed_data, size_t *decompressed_len) { - if (redis_sock->compression) { - if(redis_uncompress(redis_sock, decompressed_data, decompressed_len, data, len)) { - return 1;
View file
redis-6.2.0.tgz/redis-6.2.0/tests/RedisClusterTest.php
Deleted
@@ -1,892 +0,0 @@ -<?php defined('PHPREDIS_TESTRUN') or die("Use TestRedis.php to run tests!\n"); - -require_once __DIR__ . "/RedisTest.php"; - -/** - * Most RedisCluster tests should work the same as the standard Redis object - * so we only override specific functions where the prototype is different or - * where we're validating specific cluster mechanisms - */ -class Redis_Cluster_Test extends Redis_Test { - private $redis_types = - Redis::REDIS_STRING, - Redis::REDIS_SET, - Redis::REDIS_LIST, - Redis::REDIS_ZSET, - Redis::REDIS_HASH - ; - - private $failover_types = - RedisCluster::FAILOVER_NONE, - RedisCluster::FAILOVER_ERROR, - RedisCluster::FAILOVER_DISTRIBUTE - ; - - protected static array $seeds = ; - - private static array $seed_messages = ; - private static string $seed_source = ''; - - public function testServerInfo() { $this->markTestSkipped(); } - public function testServerInfoOldRedis() { $this->markTestSkipped(); } - - /* Tests we'll skip all together in the context of RedisCluster. The - * RedisCluster class doesn't implement specialized (non-redis) commands - * such as sortAsc, or sortDesc and other commands such as SELECT are - * simply invalid in Redis Cluster */ - public function testPipelinePublish() { $this->markTestSkipped(); } - public function testSortAsc() { $this->markTestSkipped(); } - public function testSortDesc() { $this->markTestSkipped(); } - public function testWait() { $this->markTestSkipped(); } - public function testSelect() { $this->markTestSkipped(); } - public function testReconnectSelect() { $this->markTestSkipped(); } - public function testMultipleConnect() { $this->markTestSkipped(); } - public function testDoublePipeNoOp() { $this->markTestSkipped(); } - public function testSwapDB() { $this->markTestSkipped(); } - public function testConnectException() { $this->markTestSkipped(); } - public function testTlsConnect() { $this->markTestSkipped(); } - public function testReset() { $this->markTestSkipped(); } - public function testInvalidAuthArgs() { $this->markTestSkipped(); } - public function testScanErrors() { $this->markTestSkipped(); } - - /* These 'directed node' commands work differently in RedisCluster */ - public function testConfig() { $this->markTestSkipped(); } - public function testFlushDB() { $this->markTestSkipped(); } - public function testFunction() { $this->markTestSkipped(); } - - /* Session locking feature is currently not supported in in context of Redis Cluster. - The biggest issue for this is the distribution nature of Redis cluster */ - public function testSession_lockKeyCorrect() { $this->markTestSkipped(); } - public function testSession_lockingDisabledByDefault() { $this->markTestSkipped(); } - public function testSession_lockReleasedOnClose() { $this->markTestSkipped(); } - public function testSession_ttlMaxExecutionTime() { $this->markTestSkipped(); } - public function testSession_ttlLockExpire() { $this->markTestSkipped(); } - public function testSession_lockHoldCheckBeforeWrite_otherProcessHasLock() { $this->markTestSkipped(); } - public function testSession_lockHoldCheckBeforeWrite_nobodyHasLock() { $this->markTestSkipped(); } - public function testSession_correctLockRetryCount() { $this->markTestSkipped(); } - public function testSession_defaultLockRetryCount() { $this->markTestSkipped(); } - public function testSession_noUnlockOfOtherProcess() { $this->markTestSkipped(); } - public function testSession_lockWaitTime() { $this->markTestSkipped(); } - - private function loadSeedsFromHostPort($host, $port) { - try { - $rc = new RedisCluster(NULL, "$host:$port", 1, 1, true, $this->getAuth()); - self::$seed_source = "Host: $host, Port: $port"; - return array_map(function($master) { - return sprintf('%s:%s', $master0, $master1); - }, $rc->_masters()); - } catch (Exception $ex) { - /* fallthrough */ - } - - self::$seed_messages = "--host=$host, --port=$port"; - - return false; - } - - private function loadSeedsFromEnv() { - $seeds = getenv('REDIS_CLUSTER_NODES'); - if ( ! $seeds) { - self::$seed_messages = "environment variable REDIS_CLUSTER_NODES ($seeds)"; - return false; - } - - self::$seed_source = 'Environment variable REDIS_CLUSTER_NODES'; - return array_filter(explode(' ', $seeds)); - } - - private function loadSeedsFromNodeMap() { - $nodemap_file = dirname($_SERVER'PHP_SELF') . '/nodes/nodemap'; - if ( ! file_exists($nodemap_file)) { - self::$seed_messages = "nodemap file '$nodemap_file'"; - return false; - } - - self::$seed_source = "Nodemap file '$nodemap_file'"; - return array_filter(explode("\n", file_get_contents($nodemap_file))); - } - - private function loadSeeds($host, $port) { - if (($seeds = $this->loadSeedsFromNodeMap())) - return $seeds; - if (($seeds = $this->loadSeedsFromEnv())) - return $seeds; - if (($seeds = $this->loadSeedsFromHostPort($host, $port))) - return $seeds; - - TestSuite::errorMessage("Error: Unable to load seeds for RedisCluster tests"); - foreach (self::$seed_messages as $msg) { - TestSuite::errorMessage(" Tried: %s", $msg); - } - - exit(1); - } - - /* Load our seeds on construction */ - public function __construct($host, $port, $auth) { - parent::__construct($host, $port, $auth); - - self::$seeds = $this->loadSeeds($host, $port); - } - - /* Override setUp to get info from a specific node */ - public function setUp() { - $this->redis = $this->newInstance(); - $info = $this->redis->info(uniqid()); - $this->version = $info'redis_version' ?? '0.0.0'; - $this->is_keydb = $this->detectKeyDB($info); - $this->is_valkey = $this->detectValkey($info); - } - - /* Override newInstance as we want a RedisCluster object */ - protected function newInstance() { - try { - return new RedisCluster(NULL, self::$seeds, 30, 30, true, $this->getAuth()); - } catch (Exception $ex) { - TestSuite::errorMessage("Fatal error: %s\n", $ex->getMessage()); - TestSuite::errorMessage("Seeds: %s\n", implode(' ', self::$seeds)); - TestSuite::errorMessage("Seed source: %s\n", self::$seed_source); - exit(1); - } - } - - /* Overrides for RedisTest where the function signature is different. This - * is only true for a few commands, which by definition have to be directed - * at a specific node */ - - public function testPing() { - for ($i = 0; $i < 20; $i++) { - $this->assertTrue($this->redis->ping("key:$i")); - $this->assertEquals('BEEP', $this->redis->ping("key:$i", 'BEEP')); - } - - /* Make sure both variations work in MULTI mode */ - $this->redis->multi(); - $this->redis->ping('{ping-test}'); - $this->redis->ping('{ping-test}', 'BEEP'); - $this->assertEquals(true, 'BEEP', $this->redis->exec()); - } - - public function testRandomKey() { - /* Ensure some keys are present to test */ - for ($i = 0; $i < 1000; $i++) { - if (rand(1, 2) == 1) { - $this->redis->set("key:$i", "val:$i"); - } - } - - for ($i = 0; $i < 1000; $i++) { - $k = $this->redis->randomKey("key:$i"); - $this->assertEquals(1, $this->redis->exists($k)); - } - } - - public function testEcho() { - $this->assertEquals('hello', $this->redis->echo('echo1', 'hello')); - $this->assertEquals('world', $this->redis->echo('echo2', 'world')); - $this->assertEquals(' 0123 ', $this->redis->echo('echo3', " 0123 ")); - } - - public function testSortPrefix() { - $this->redis->setOption(Redis::OPT_PREFIX, 'some-prefix:'); - $this->redis->del('some-item'); - $this->redis->sadd('some-item', 1); - $this->redis->sadd('some-item', 2); - $this->redis->sadd('some-item', 3); - - $this->assertEquals('1', '2', '3', $this->redis->sort('some-item')); - - // Kill our set/prefix
View file
redis-6.2.0.tgz/redis-6.2.0/tests/RedisSentinelTest.php
Deleted
@@ -1,119 +0,0 @@ -<?php defined('PHPREDIS_TESTRUN') or die("Use TestRedis.php to run tests!\n"); - -require_once __DIR__ . "/TestSuite.php"; - -class Redis_Sentinel_Test extends TestSuite -{ - const NAME = 'mymaster'; - - /** - * @var RedisSentinel - */ - public $sentinel; - - /** - * Common fields - */ - protected $fields = - 'name', - 'ip', - 'port', - 'runid', - 'flags', - 'link-pending-commands', - 'link-refcount', - 'last-ping-sent', - 'last-ok-ping-reply', - 'last-ping-reply', - 'down-after-milliseconds', - ; - - protected function newInstance() - { - return new RedisSentinel('host' => $this->getHost()); - } - - public function setUp() - { - $this->sentinel = $this->newInstance(); - } - - public function testCkquorum() - { - $this->assertTrue($this->sentinel->ckquorum(self::NAME)); - } - - public function testFailover() - { - $this->assertFalse($this->sentinel->failover(self::NAME)); - } - - public function testFlushconfig() - { - $this->assertTrue($this->sentinel->flushconfig()); - } - - public function testGetMasterAddrByName() - { - $result = $this->sentinel->getMasterAddrByName(self::NAME); - $this->assertTrue(is_array($result)); - $this->assertEquals(2, count($result)); - } - - protected function checkFields(array $fields) - { - foreach ($this->fields as $k) { - $this->assertTrue(array_key_exists($k, $fields)); - } - } - - public function testMaster() - { - $result = $this->sentinel->master(self::NAME); - $this->assertTrue(is_array($result)); - $this->checkFields($result); - } - - public function testMasters() - { - $result = $this->sentinel->masters(); - $this->assertTrue(is_array($result)); - foreach ($result as $master) { - $this->checkFields($master); - } - } - - public function testMyid() - { - $result = $this->sentinel->myid(); - $this->assertTrue(is_string($result)); - } - - public function testPing() - { - $this->assertTrue($this->sentinel->ping()); - } - - public function testReset() - { - $this->assertEquals(1, $this->sentinel->reset('*')); - } - - public function testSentinels() - { - $result = $this->sentinel->sentinels(self::NAME); - $this->assertTrue(is_array($result)); - foreach ($result as $sentinel) { - $this->checkFields($sentinel); - } - } - - public function testSlaves() - { - $result = $this->sentinel->slaves(self::NAME); - $this->assertTrue(is_array($result)); - foreach ($result as $slave) { - $this->checkFields($slave); - } - } -}
View file
redis-6.2.0.tgz/redis-6.2.0/tests/RedisTest.php
Deleted
@@ -1,8036 +0,0 @@ -<?php defined('PHPREDIS_TESTRUN') or die('Use TestRedis.php to run tests!\n'); - -require_once __DIR__ . '/TestSuite.php'; -require_once __DIR__ . '/SessionHelpers.php'; - -class Redis_Test extends TestSuite { - /** - * @var Redis - */ - public $redis; - - /* City lat/long */ - protected $cities = - 'Chico' => -121.837478, 39.728494, - 'Sacramento' => -121.494400, 38.581572, - 'Gridley' => -121.693583, 39.363777, - 'Marysville' => -121.591355, 39.145725, - 'Cupertino' => -122.032182, 37.322998 - ; - - protected $serializers = - Redis::SERIALIZER_NONE, - Redis::SERIALIZER_PHP, - ; - - protected function getNilValue() { - return FALSE; - } - - protected function getSerializers() { - $result = Redis::SERIALIZER_NONE, Redis::SERIALIZER_PHP; - - if (defined('Redis::SERIALIZER_IGBINARY')) - $result = Redis::SERIALIZER_IGBINARY; - if (defined('Redis::SERIALIZER_JSON')) - $result = Redis::SERIALIZER_JSON; - if (defined('Redis::SERIALIZER_MSGPACK')) - $result = Redis::SERIALIZER_MSGPACK; - - return $result; - } - - protected function getCompressors() { - $result'none' = Redis::COMPRESSION_NONE; - if (defined('Redis::COMPRESSION_LZF')) - $result'lzf' = Redis::COMPRESSION_LZF; - if (defined('Redis::COMPRESSION_LZ4')) - $result'lz4' = Redis::COMPRESSION_LZ4; - if (defined('Redis::COMPRESSION_ZSTD')) - $result'zstd' = Redis::COMPRESSION_ZSTD; - - return $result; - } - - /* Overridable left/right constants */ - protected function getLeftConstant() { - return Redis::LEFT; - } - - protected function getRightConstant() { - return Redis::RIGHT; - } - - protected function detectKeyDB(array $info) { - return strpos($info'executable' ?? '', 'keydb') !== false || - isset($info'keydb') || - isset($info'mvcc_depth'); - } - - protected function detectValkey(array $info) { - return isset($info'server_name') && $info'server_name' === 'valkey'; - } - - public function setUp() { - $this->redis = $this->newInstance(); - $info = $this->redis->info(); - $this->version = (isset($info'redis_version')?$info'redis_version':'0.0.0'); - $this->is_keydb = $this->detectKeyDB($info); - $this->is_valkey = $this->detectValKey($info); - } - - protected function minVersionCheck($version) { - return version_compare($this->version, $version) >= 0; - } - - protected function mstime() { - return round(microtime(true)*1000); - } - - protected function getAuthParts(&$user, &$pass) { - $user = $pass = NULL; - - $auth = $this->getAuth(); - if ( ! $auth) - return; - - if (is_array($auth)) { - if (count($auth) > 1) { - list($user, $pass) = $auth; - } else { - $pass = $auth0; - } - } else { - $pass = $auth; - } - } - - protected function sessionPrefix(): string { - return 'PHPREDIS_SESSION:'; - } - - protected function sessionSaveHandler(): string { - return 'redis'; - } - - protected function sessionSavePath(): string { - return sprintf('tcp://%s:%d?%s', $this->getHost(), $this->getPort(), - $this->getAuthFragment()); - } - - protected function getAuthFragment() { - $this->getAuthParts($user, $pass); - - if ($user && $pass) { - return sprintf('authuser=%s&authpass=%s', $user, $pass); - } else if ($pass) { - return sprintf('authpass=%s', $pass); - } else { - return ''; - } - } - - protected function newInstance() { - $r = new Redis( - 'host' => $this->getHost(), - 'port' => $this->getPort(), - ); - - if ($this->getAuth()) { - $this->assertTrue($r->auth($this->getAuth())); - } - return $r; - } - - public function tearDown() { - if ($this->redis) { - $this->redis->close(); - } - } - - public function reset() { - $this->setUp(); - $this->tearDown(); - } - - /* Helper function to determine if the class has pipeline support */ - protected function havePipeline() { - return defined(get_class($this->redis) . '::PIPELINE'); - } - - protected function haveMulti() { - return defined(get_class($this->redis) . '::MULTI'); - } - - public function testMinimumVersion() { - $this->assertTrue(version_compare($this->version, '2.4.0') >= 0); - } - - public function testPing() { - /* Reply literal off */ - $this->assertTrue($this->redis->ping()); - $this->assertTrue($this->redis->ping(NULL)); - $this->assertEquals('BEEP', $this->redis->ping('BEEP')); - - /* Make sure we're good in MULTI mode */ - if ($this->haveMulti()) { - $this->assertEquals( - true, 'BEEP', - $this->redis->multi() - ->ping() - ->ping('BEEP') - ->exec() - ); - } - } - - public function testPipelinePublish() { - $ret = $this->redis->pipeline() - ->publish('chan', 'msg') - ->exec(); - - $this->assertIsArray($ret, 1); - $this->assertGT(-1, $ret0 ?? -1); - } - - // Run some simple tests against the PUBSUB command. This is problematic, as we - // can't be sure what's going on in the instance, but we can do some things. - public function testPubSub() { - // Only available since 2.8.0
View file
redis-6.2.0.tgz/redis-6.2.0/tests/SessionHelpers.php
Deleted
@@ -1,353 +0,0 @@ -<?php - -namespace SessionHelpers; - -class PhpSpawner { - protected static function appendPhpArgs(string $php): string { - $modules = shell_exec("$php --no-php-ini -m"); - - /* Determine if we need to specifically add extensions */ - $extensions = array_filter( - 'igbinary', 'msgpack', 'json', 'redis', - function ($module) use ($modules) { - return strpos($modules, $module) === false; - } - ); - - /* If any are needed add them to the command */ - if ($extensions) { - $php .= ' --no-php-ini'; - foreach ($extensions as $extension) { - /* We want to use the locally built redis extension */ - if ($extension == 'redis') { - $path = dirname(__DIR__) . '/modules/redis'; - if (is_file("{$path}.so")) - $extension = $path; - } - - $php .= " -dextension=$extension.so"; - } - } - - return $php; - } - - /** - * Return command to launch PHP with built extension enabled - * taking care of environment (TEST_PHP_EXECUTABLE and TEST_PHP_ARGS) - * - * @param string $script - * - * @return string - */ - public static function cmd(string $script): string { - static $cmd = NULL; - - if ( ! $cmd) { - $cmd = getenv('TEST_PHP_EXECUTABLE') ?: PHP_BINARY; - - if ($test_args = getenv('TEST_PHP_ARGS')) { - $cmd .= ' ' . $test_args; - } else { - $cmd = self::appendPhpArgs($cmd); - } - } - - return $cmd . ' ' . __DIR__ . '/' . $script . ' '; - } -} - -class Runner { - const start_script = 'startSession.php'; - const regenerate_id_script = 'regenerateSessionId.php'; - const get_data_script = 'getSessionData.php'; - - private $required = 'host', 'handler', 'id'; - - private $args = - 'handler' => null, - 'save-path' => null, - 'id' => null, - 'sleep' => 0, - 'max-execution-time' => 300, - 'locking-enabled' => true, - 'lock-wait-time' => null, - 'lock-retries' => -1, - 'lock-expires' => 0, - 'data' => '', - 'lifetime' => 1440, - 'compression' => 'none', - ; - - private $prefix = NULL; - private $output_file; - private $exit_code = -1; - private $cmd = NULL; - private $pid; - private $output; - - public function __construct() { - $this->args'id' = $this->createId(); - } - - public function getExitCode(): int { - return $this->exit_code; - } - - public function getCmd(): ?string { - return $this->cmd; - } - - public function getId(): ?string { - return $this->args'id'; - } - - public function prefix(string $prefix): self { - $this->prefix = $prefix; - return $this; - } - - public function getSessionKey(): string { - return $this->prefix . $this->getId(); - } - - public function getSessionLockKey(): string { - return $this->getSessionKey() . '_LOCK'; - } - - protected function set($setting, $v): self { - $this->args$setting = $v; - return $this; - } - - public function handler(string $handler): self { - return $this->set('handler', $handler); - } - - public function savePath(string $path): self { - return $this->set('save-path', $path); - } - - public function id(string $id): self { - return $this->set('id', $id); - } - - public function sleep(int $sleep): self { - return $this->set('sleep', $sleep); - } - - public function maxExecutionTime(int $time): self { - return $this->set('max-execution-time', $time); - } - - public function lockingEnabled(bool $enabled): self { - return $this->set('locking-enabled', $enabled); - } - - public function lockWaitTime(int $time): self { - return $this->set('lock-wait-time', $time); - } - - public function lockRetries(int $retries): self { - return $this->set('lock-retries', $retries); - } - - public function lockExpires(int $expires): self { - return $this->set('lock-expires', $expires); - } - - public function data(string $data): self { - return $this->set('data', $data); - } - - public function lifetime(int $lifetime): self { - return $this->set('lifetime', $lifetime); - } - - public function compression(string $compression): self { - return $this->set('compression', $compression); - } - - protected function validateArgs(array $required) { - foreach ($required as $req) { - if ( ! isset($this->args$req) || $this->args$req === null) - throw new \Exception("Command requires '$req' arg"); - } - } - - private function createId(): string { - if (function_exists('session_create_id')) - return session_create_id(); - - return uniqid(); - } - - private function getTmpFileName() { - return '/tmp/sessiontmp.txt'; - return tempnam(sys_get_temp_dir(), 'session'); - } - - /* - * @param $client Redis client - * @param string $max_wait_sec - * - * Sometimes we want to block until a session lock has been detected - * This is better and faster than arbitrarily sleeping. If we don't - * detect the session key within the specified maximum number of - * seconds, the function returns failure. - * - * @return bool
View file
redis-6.2.0.tgz/redis-6.2.0/tests/TestSuite.php
Deleted
@@ -1,638 +0,0 @@ -<?php defined('PHPREDIS_TESTRUN') or die("Use TestRedis.php to run tests!\n"); - -/* A specific exception for when we skip a test */ -class TestSkippedException extends Exception {} - -// phpunit is such a pain to install, we're going with pure-PHP here. -class TestSuite -{ - /* Host and port the unit tests will use */ - private string $host; - private ?int $port = 6379; - - /* Redis authentication we'll use */ - private $auth; - - /* Redis server version */ - protected $version; - protected bool $is_keydb; - protected bool $is_valkey; - - private static bool $colorize = false; - - private static $BOLD_ON = "\0331m"; - private static $BOLD_OFF = "\0330m"; - - private static $BLACK = "\0330;30m"; - private static $DARKGRAY = "\0331;30m"; - private static $BLUE = "\0330;34m"; - private static $PURPLE = "\0330;35m"; - private static $GREEN = "\0330;32m"; - private static $YELLOW = "\0330;33m"; - private static $RED = "\0330;31m"; - - public static array $errors = ; - public static array $warnings = ; - - public function __construct(string $host, ?int $port, $auth) { - $this->host = $host; - $this->port = $port; - $this->auth = $auth; - } - - public function getHost() { return $this->host; } - public function getPort() { return $this->port; } - public function getAuth() { return $this->auth; } - - public static function errorMessage(string $fmt, ...$args) { - $msg = vsprintf($fmt . "\n", $args); - - if (defined('STDERR')) { - fwrite(STDERR, $msg); - } else { - echo $msg; - } - } - - public static function make_bold(string $msg) { - return self::$colorize ? self::$BOLD_ON . $msg . self::$BOLD_OFF : $msg; - } - - public static function make_success(string $msg) { - return self::$colorize ? self::$GREEN . $msg . self::$BOLD_OFF : $msg; - } - - public static function make_fail(string $msg) { - return self::$colorize ? self::$RED . $msg . self::$BOLD_OFF : $msg; - } - - public static function make_warning(string $msg) { - return self::$colorize ? self::$YELLOW . $msg . self::$BOLD_OFF : $msg; - } - - protected function printArg($v) { - if (is_null($v)) - return '(null)'; - else if ($v === false || $v === true) - return $v ? '(true)' : '(false)'; - else if (is_string($v)) - return "'$v'"; - else - return print_r($v, true); - } - - protected function findTestFunction($bt) { - $i = 0; - while (isset($bt$i)) { - if (substr($bt$i'function', 0, 4) == 'test') - return $bt$i'function'; - $i++; - } - return NULL; - } - - protected function assertionTrace(?string $fmt = NULL, ...$args) { - $prefix = 'Assertion failed:'; - - $lines = ; - - $bt = debug_backtrace(); - - $msg = $fmt ? vsprintf($fmt, $args) : NULL; - - $fn = $this->findTestFunction($bt); - $lines = sprintf("%s %s - %s", $prefix, self::make_bold($fn), - $msg ? $msg : '(no message)'); - - array_shift($bt); - - for ($i = 0; $i < count($bt); $i++) { - $file = $bt$i'file'; - $line = $bt$i'line'; - $fn = $bt$i+1'function' ?? $bt$i'function'; - - $lines = sprintf("%s %s:%d (%s)%s", - str_repeat(' ', strlen($prefix)), $file, $line, - $fn, $msg ? " $msg" : ''); - - if (substr($fn, 0, 4) == 'test') - break; - } - - return implode("\n", $lines) . "\n"; - } - - protected function assert($fmt, ...$args) { - self::$errors = $this->assertionTrace($fmt, ...$args); - } - - protected function assertKeyEquals($expected, $key, $redis = NULL): bool { - $actual = ($redis ??= $this->redis)->get($key); - if ($actual === $expected) - return true; - - self::$errors = $this->assertionTrace("%s !== %s", $this->printArg($actual), - $this->printArg($expected)); - - return false; - } - - protected function assertKeyEqualsWeak($expected, $key, $redis = NULL): bool { - $actual = ($redis ??= $this->redis)->get($key); - if ($actual == $expected) - return true; - - self::$errors = $this->assertionTrace("%s != %s", $this->printArg($actual), - $this->printArg($expected)); - - return false; - } - - protected function assertKeyExists($key, $redis = NULL): bool { - if (($redis ??= $this->redis)->exists($key)) - return true; - - self::$errors = $this->assertionTrace("Key '%s' does not exist.", $key); - - return false; - } - - protected function assertKeyMissing($key, $redis = NULL): bool { - if ( ! ($redis ??= $this->redis)->exists($key)) - return true; - - self::$errors = $this->assertionTrace("Key '%s' exists but shouldn't.", $key); - - return false; - } - - protected function assertTrue($value): bool { - if ($value === true) - return true; - - self::$errors = $this->assertionTrace("%s !== %s", $this->printArg($value), - $this->printArg(true)); - - return false; - } - - protected function assertFalse($value): bool { - if ($value === false) - return true; - - self::$errors = $this->assertionTrace("%s !== %s", $this->printArg($value), - $this->printArg(false)); - - return false; - } - - protected function assertNull($value): bool { - if ($value === NULL) - return true; - - self::$errors = $this->assertionTrace("%s !== %s", $this->printArg($value), - $this->printArg(NULL)); - - return false; - } - - protected function assertInArray($ele, $arr, ?callable $cb = NULL): bool {
View file
redis-6.2.0.tgz/package.xml -> redis-6.3.0.tgz/package.xml
Changed
@@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ISO-8859-1"?> -<package packagerversion="1.10.12" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> +<package packagerversion="1.10.16" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>redis</name> <channel>pecl.php.net</channel> <summary>PHP extension for interfacing with key-value stores</summary> @@ -17,10 +17,10 @@ <email>p.yatsukhnenko@gmail.com</email> <active>yes</active> </lead> - <date>2025-03-24</date> - <time>19:00:47</time> + <date>2025-11-06</date> + <time>19:50:19</time> <version> - <release>6.2.0</release> + <release>6.3.0</release> <api>6.2.0</api> </version> <stability> @@ -31,73 +31,26 @@ <notes> --- Sponsors --- -A-VISION Advisering - https://a-vision.nu/ -Audiomack - https://audiomack.com +A-VISION Advertising - https://github.com/A-VISION-BV Avtandil Kikabidze - https://github.com/akalongman Geoffrey Hoffman - https://github.com/phpguru -Object Cache Pro for WordPress - https://objectcache.pro -Open LMS - https://openlms.net +Object Cache Pro for WordPress - https://objectcache.pro/ +Open LMS - https://openlms.net/ +Relay - https://relay.so Salvatore Sanfilippo - https://github.com/antirez Ty Karok - https://github.com/karock -Vanessa Santana - https://github.com/vanessa-dev -* A special thanks to Jakub Onderka for nearly two dozen performance improvements in this release! +--- 6.3.0 --- ---- 6.2.0 --- +This release introduces support for dozens of new commands, including hash +field expiration, Valkey?s DELIFEQ, and Redis vector set commands. It also +includes many bug fixes and performance improvements. Fixed: -* Fix arguments order for SET command f73f5fc (Pavlo Yatsukhnenko) -* Fix error length calculation and UB sanity check e73130fe (michael-grunder) -* Invalidate slot cache on failed cluster connections c7b87843 (James Kennedy) -* Don't cast a uint64_t to a long faa4bc20 (michael-grunder) -* Fix potential NULL dereference 43e6cab8 (peter15914) -* Print cursor as unsigned 64 bit integer 138d07b6 (Bentley O'Kane-Chase) -* Fix XAUTOCLAIM argc when sending COUNT 0fe45d24 (michael-grunder) -Added: -* Added `serverName()` and `serverVersion()` fa3eb006, cbaf095f, 056c2dbe - (Pavlo Yatsukhnenko, Michael Grunder) -* Added getWithMeta method 9036ffca, 36ab5850 (Pavlo Yatsukhnenko) -* Implement GETDEL command for RedisCluster d342e4ac (michael-grunder) -* Introduce Redis::OPT_PACK_IGNORE_NUMBERS option f9ce9429, 29e5cf0d (michael-grunder) -* Implement Valkey >= 8.1 IFEQ SET option a2eef77f (michael-grunder) -* Implement KeyDB's EXPIREMEMBERAT commands 4cd3f593 (michael-grunder) - -Documentation: -* Fix phpdoc type of $pattern 5cad2076 (OHZEKI Naoki) -* Better documentation for the $tlsOptions parameter of RedisCluster 8144db37 (Jacob Brown) - -Tests/CI: -* Add details to the option doc block abb0f6cc (michael-grunder) -* Update CodeQL to v3 41e11417, a10bca35 (Pavlo Yatsukhnenko) -* Add PHP 8.4 to CI 6097e7ba (Pavlo Yatsukhnenko) -* Pin ubuntu version for KeyDB eb66fc9e, 985b0313 (michael-grunder) -* Windows CI: update setup-php-sdk to v0.10 and enable caching f89d4d8f (Christoph M. Becker) - -Internal: -* Reduce buffer size for signed integer 044b3038, 35c59880 (Bentley O'Kane-Chase) -* Create a strncmp wrapper 085d61ec (michael-grunder) -* Refactor and avoid allocation in rawcommand method f68544f7 (Jakub Onderka) -* Use defines for callback growth + sanity check 42a42769 (michael-grunder) -* Switch from linked list to growing array for reply callbacks a551fdc9 (Jakub Onderka) -* Reuse redis_sock_append_auth method be388562 (Jakub Onderka) -* Switch pipeline_cmd from smart_str to smart_string 571ffbc8 (Jakub Onderka) -* Remove unused redis_debug_response method from library.c 7895636a (Jakub Onderka) -* Optimise HMGET method 2434ba29 (Jakub Onderka) -* Avoid unnecessary allocation in redis_hset_cmd aba09933 (Jakub Onderka) -* Avoid unnecessary allocation in redis_hdel_cmd 4082dd07 (Jakub Onderka) -* Avoid unnecessary allocation in redis_key_varval_cmd 99650e15 (Jakub Onderka) -* Use zval_get_tmp_string method that is faster when provided zval is string f6906470 (Jakub Onderka) -* Optimise constructing Redis command string 2a2f908f (Jakub Onderka) -* If no command is issued in multi mode, return immutable empty array 5156e032 (Jakub Onderka) -* Test for empty pipeline and multi 426de2bb (Jakub Onderka) -* Optimise method array_zip_values_and_scores 400503b8 (Jakub Onderka) -* Faster parameter parsing in redis_key_cmd and redis_key_long_val_cmd 83a19656 (Jakub Onderka) -* Use immutable empty array in Redis::hKeys 3a2f3f45 (Jakub Onderka) -* Use immutable empty array in Redis::exec 60b5a886 (Jakub Onderka) -* Do not allocate empty string or string with one character 64da891e (Jakub Onderka) -* Initialize arrays with known size 99beb922 (Jakub Onderka) -* Use smart str for constructing pipeline cmd b665925e (Jakub Onderka) +* Cloning our objects should not segfault 770034cc (michael-grunder) +* Fix return type for `RedisCluster` `vgetattr` and `vsetattr` + 834d2b37 (michael-grunder) </notes> <contents> <dir name="/"> @@ -108,54 +61,54 @@ <file md5sum="f56a91842e1a56820efe3f35fcfa486e" name="liblzf/lzf_c.c" role="src" /> <file md5sum="ef8f82dbd4bad7b83629c02724afcfd0" name="liblzf/lzf_d.c" role="src" /> <file md5sum="429188b3d5c91f528dcca6e4e1653840" name="tests/RedisArrayTest.php" role="test" /> - <file md5sum="868fbc592f577551ea1dd8e10157ac80" name="tests/RedisClusterTest.php" role="test" /> - <file md5sum="94a8cf559d1a40ddc96fb55effb372ee" name="tests/RedisSentinelTest.php" role="test" /> - <file md5sum="24386d59ec0d05bd4bfe990c485ff377" name="tests/RedisTest.php" role="test" /> + <file md5sum="410b595ba9f100d607251240ae8c96b6" name="tests/RedisClusterTest.php" role="test" /> + <file md5sum="ac19b2b3b74459ddf35ad77571c8e141" name="tests/RedisSentinelTest.php" role="test" /> + <file md5sum="482148cc30b0041808afbacf05700577" name="tests/RedisTest.php" role="test" /> <file md5sum="94d564eb6d04723a987854e187a9c8d4" name="tests/TestRedis.php" role="test" /> - <file md5sum="5edc87828956490295b145d29ae8ffc9" name="tests/TestSuite.php" role="test" /> + <file md5sum="357dc08e5102e53ad150fe6eaa615135" name="tests/TestSuite.php" role="test" /> <file md5sum="f8ba6ee263cf5cdbfe9242513302f24c" name="tests/getSessionData.php" role="test" /> <file md5sum="e2c0e0b4e6b027cee1a444abffa0601e" name="tests/regenerateSessionId.php" role="test" /> <file md5sum="2272f4aa4f2febe66a34661464bffc57" name="tests/startSession.php" role="test" /> - <file md5sum="202035ead99dca010e110f9cca79d9c7" name="tests/SessionHelpers.php" role="test" /> + <file md5sum="1c27d9ec328cb14b4fa79c00a02530b6" name="tests/SessionHelpers.php" role="test" /> <file md5sum="654496adb29b43100f4a98c8c4127d4e" name="tests/make-cluster.sh" role="test" /> <file md5sum="e9ddcb5f7abcef8507c394d8386f4742" name="tests/mkring.sh" role="test" /> <file md5sum="cb564efdf78cce8ea6e4b5a4f7c05d97" name="LICENSE" role="doc" /> <file md5sum="d56374bf738d2b10cb1f97cd7c9cfb30" name="CREDITS" role="doc" /> - <file md5sum="b363573ea0afeea20c55fc81a2fda803" name="README.md" role="doc" /> - <file md5sum="31492dbbf5b3a49cb95c7a304efd2313" name="INSTALL.md" role="src" /> + <file md5sum="143d276e3b4819e605699ac770ed6344" name="README.md" role="doc" /> + <file md5sum="dcf388e2e97cd21a297cbd7d6a255eed" name="INSTALL.md" role="src" /> <file md5sum="12ce8871013788f5b3abc69691fb5a7d" name="arrays.md" role="doc" /> <file md5sum="072c67a36ff418d3c963c99f767b2203" name="cluster.md" role="doc" /> <file md5sum="ce0ab3a589e5a034beebced11be601d7" name="sentinel.md" role="doc" /> <file md5sum="13936f0c8e8d3860fa45f941333ae8aa" name="backoff.c" role="src" /> <file md5sum="af0b29580d83ba055ff816664d7f3d83" name="backoff.h" role="src" /> - <file md5sum="654787f8d0e51798e19bb55e59eb42b6" name="cluster_library.c" role="src" /> - <file md5sum="c6e5011da50c08e6aa95fa10de1bd9d6" name="cluster_library.h" role="src" /> - <file md5sum="ebf2923eecfdf7e4b025d63310f4e387" name="common.h" role="src" /> + <file md5sum="17007e008f3b59e574877476681d1649" name="cluster_library.c" role="src" /> + <file md5sum="114df8bf99a932d46f51935b21e384b8" name="cluster_library.h" role="src" /> + <file md5sum="54e97b2509b5d8d9d739d0d7edab5cb6" name="common.h" role="src" /> <file md5sum="9b37d3cd4dc9cd9369322b69766b7165" name="config.m4" role="src" /> <file md5sum="c962cae928bcb4986ebb17bf9d5a3811" name="config.w32" role="src" /> <file md5sum="b21982c70ca8292b4ac540a76cd3bac4" name="crc16.h" role="src" /> - <file md5sum="31f122a8d9794844c96ae48783bfe741" name="library.c" role="src" /> - <file md5sum="7d6885acc7d9247309dbfbb67b919dbd" name="library.h" role="src" /> - <file md5sum="4f7eec17b48b2cf39f1770657fb8f0f8" name="php_redis.h" role="src" /> - <file md5sum="40d48396b7e33a63c16332b37115470c" name="redis.c" role="src" /> - <file md5sum="4f0ff1839c329172e4035d3702ee3357" name="redis.stub.php" role="src" /> - <file md5sum="8086e5f124074bcad4dc0a456d0cbcbc" name="redis_arginfo.h" role="src" /> - <file md5sum="a4ac9a3186c156669e502740f8933800" name="redis_legacy_arginfo.h" role="src" /> - <file md5sum="45dc2c335c3fbd274d0567d77e509082" name="redis_array.c" role="src" /> + <file md5sum="f8a677b3109418572944eb72e9c859d6" name="library.c" role="src" /> + <file md5sum="0a723f18d2b62f6d62995b15a8ce210f" name="library.h" role="src" /> + <file md5sum="34881e6ab07a96e46da6b566bb3652ef" name="php_redis.h" role="src" /> + <file md5sum="51a1b1b37cd6cb4d77fe972f0484bd38" name="redis.c" role="src" /> + <file md5sum="ec053cc6b0d1d2ea04103b2ec18a6097" name="redis.stub.php" role="src" /> + <file md5sum="7f48f4206afb27670e331130281f8e2a" name="redis_arginfo.h" role="src" /> + <file md5sum="47e1661a50487baa94380e53e9e445b4" name="redis_legacy_arginfo.h" role="src" /> + <file md5sum="e9d3839e3f5f654f3b6e78d5a601d538" name="redis_array.c" role="src" /> <file md5sum="6bccb2758b3625ccdc183a8a9ee4e4c4" name="redis_array.h" role="src" /> <file md5sum="d6b4544e2563087cd81a8e9ad747535e" name="redis_array.stub.php" role="src" /> <file md5sum="14520411b0ef3f66db4c00a309714f39" name="redis_array_arginfo.h" role="src" /> <file md5sum="4b29ca76bb3efe98e333ef899f99ccc4" name="redis_array_legacy_arginfo.h" role="src" /> - <file md5sum="a6379f4be513741492ca9e216b300ac0" name="redis_array_impl.c" role="src" /> + <file md5sum="101eb8451496fb76a64751a2daa3c3be" name="redis_array_impl.c" role="src" /> <file md5sum="17beb987bc073372d9ee903db1b37410" name="redis_array_impl.h" role="src" /> - <file md5sum="8624c4476d3e62d7d15b8b5bd1cde9e3" name="redis_cluster.c" role="src" /> - <file md5sum="6d218da21a7f9bc2f1ce1f5736b6c2ec" name="redis_cluster.h" role="src" /> - <file md5sum="14e76f88ce122e9e3c241a0cc682255e" name="redis_cluster.stub.php" role="src" /> - <file md5sum="dd433726298cb1dbc88bb847008fd3f9" name="redis_cluster_arginfo.h" role="src" /> - <file md5sum="b6463ae166ba25de8d8f36196b119a85" name="redis_cluster_legacy_arginfo.h" role="src" /> - <file md5sum="c1340844a7ae519d2822f4300ad46994" name="redis_commands.c" role="src" /> - <file md5sum="128e43dda80dfa8b73da869cf2b77b6b" name="redis_commands.h" role="src" /> - <file md5sum="5736f0b9d453e1f7f6b0e90cb444047c" name="redis_session.c" role="src" /> + <file md5sum="bda5ef7955b695119ba2ff04bcf202c8" name="redis_cluster.c" role="src" /> + <file md5sum="55ad8397be22730ed350c3092b77b115" name="redis_cluster.h" role="src" /> + <file md5sum="9ee518916f6368b77cd618ba9a0af4b2" name="redis_cluster.stub.php" role="src" /> + <file md5sum="adb830782f5cc2ad02eba61b25de393d" name="redis_cluster_arginfo.h" role="src" /> + <file md5sum="ae7920a2f6761dcc70f17a0d3fc54f62" name="redis_cluster_legacy_arginfo.h" role="src" /> + <file md5sum="f21b54c864fcde21419381d33057aa0c" name="redis_commands.c" role="src" /> + <file md5sum="2570903e77bd611bbdbace9c0010f4eb" name="redis_commands.h" role="src" /> + <file md5sum="47019588776beefc1e14ef901f4347c9" name="redis_session.c" role="src" /> <file md5sum="e1415ac598c012701941994aae8c3ee2" name="redis_session.h" role="src" /> <file md5sum="2a81e3aeee1280e23db57656d6c44437" name="redis_sentinel.c" role="src" /> <file md5sum="707b98f9fca6190355d7db8f95594c5e" name="redis_sentinel.h" role="src" /> @@ -192,6 +145,152 @@ <api>stable</api> </stability> <version> + <release>6.3.0</release> + <api>6.2.0</api> + </version> + <date>2025-11-06</date> + <notes> +--- Sponsors --- + +A-VISION Advertising - https://github.com/A-VISION-BV
View file
redis-6.3.0.tgz/redis-6.3.0/CREDITS
Changed
(renamed from redis-6.2.0/CREDITS)
View file
redis-6.3.0.tgz/redis-6.3.0/INSTALL.md
Added
@@ -0,0 +1,108 @@ +# Installation with PIE from packagist + +To pull latest stable released version, from packagist(https://packagist.org/packages/phpredis/phpredis) + +~~~ +pie install phpredis/phpredis +~~~ + +# Installation from pecl + +To pull latest stable released version, from pecl(https://pecl.php.net/package/redis) + +~~~ +pecl install redis +~~~ + +Configure options can be passed as well: + +```bash +pecl install --configureoptions="enable-redis-msgpack='yes' enable-redis-igbinary='yes'" redis +``` + +# Installation from sources + +To build this extension for the sources tree: + +~~~ +git clone https://github.com/phpredis/phpredis.git +cd phpredis +phpize +./configure --enable-redis-igbinary --enable-redis-msgpack --enable-redis-lzf --with-liblzf=DIR --enable-redis-zstd --enable-redis-lz4 +make && make install +~~~ + +If you would like phpredis to serialize your data using the igbinary library, run configure with `--enable-redis-igbinary`. +If you would like to use the msgpack serializer, run configure with `--enable-redis-msgpack` (note: Requires php-msgpack >= 2.0.3) +The extension also may compress data before sending it to Redis server, if you run configure with `--enable-redis-lzf`. If you want to use lzf library pre-installed into your system use `--with-liblzf` configuration option to specify the path where to search files. +`make install` copies `redis.so` to an appropriate location, but you still need to enable the module in the PHP config file. To do so, either edit your php.ini or add a redis.ini file in `/etc/php5/conf.d` with the following contents: `extension=redis.so`. + +You can generate a debian package for PHP5, accessible from Apache 2 by running `./mkdeb-apache2.sh` or with `dpkg-buildpackage` or `svn-buildpackage`. + +This extension exports a single class, Redis(./README.md#class-redis) (and RedisException(./README.md#class-redisexception) used in case of errors). Check out https://github.com/ukko/phpredis-phpdoc for a PHP stub that you can use in your IDE for code completion. + + +# Binary packages + +Most distributions provides pre-build binary packages of this extension. + +## Windows: + +Follow the DLL link on the https://pecl.php.net/package/redis(https://pecl.php.net/package/redis) page or use https://windows.php.net/downloads/pecl/releases/redis/(https://windows.php.net/downloads/pecl/releases/redis/) + +## Fedora + +Fedora users can install the package from the official repository. + +### Fedora ≥ 40, Version 6 + +Installation of the php-pecl-redis6(https://src.fedoraproject.org/rpms/php-pecl-redis6/) package: + +~~~ +dnf install php-redis +~~~ + +## CentOS / RHEL and clones + +Installation of the php-pecl-redis6 package, available for PHP ≥ 8.3: + +~~~ +dnf install php-redis +~~~ + +### openSUSE ≥ 15.1 + +Installation of the php7-redis(https://software.opensuse.org/package/php7-redis?search_term=php7-redis) package: + +~~~ +zypper in php7-redis +~~~ + + +# Installation on OSX + +If the install fails on OSX, type the following commands in your shell before trying again: +~~~ +MACOSX_DEPLOYMENT_TARGET=10.6 +CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" +CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" +CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" +LDFLAGS="-arch i386 -arch x86_64 -bind_at_load" +export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET +~~~ + +If that still fails and you are running Zend Server CE, try this right before "make": `./configure CFLAGS="-arch i386"`. + +Taken from Compiling phpredis on Zend Server CE/OSX (http://www.tumblr.com/tagged/phpredis). + +See also: Install Redis & PHP Extension PHPRedis with Macports(http://www.lecloud.net/post/3378834922/install-redis-php-extension-phpredis-with-macports). + +You can install it using MacPorts: + +- Get macports-php(https://www.macports.org/) +- `sudo port install php56-redis` (or php53-redis, php54-redis, php55-redis, php70-redis, php71-redis, php72-redis, php73-redis, php74-redis) + +# Building on Windows + +See instructions from @char101(https://github.com/phpredis/phpredis/issues/213#issuecomment-11361242) on how to build phpredis on Windows. +
View file
redis-6.3.0.tgz/redis-6.3.0/LICENSE
Changed
(renamed from redis-6.2.0/LICENSE)
View file
redis-6.3.0.tgz/redis-6.3.0/README.md
Added
@@ -0,0 +1,4577 @@ +# PhpRedis + +!Build Status(https://github.com/phpredis/phpredis/actions/workflows/ci.yml/badge.svg)(https://github.com/phpredis/phpredis/actions/workflows/ci.yml) +!Coverity Scan Build Status(https://scan.coverity.com/projects/13205/badge.svg)(https://scan.coverity.com/projects/phpredis-phpredis) +!PHP version(https://img.shields.io/badge/php-%3E%3D%207.4-8892BF.svg)(https://github.com/phpredis/phpredis) + +The phpredis extension provides an API for communicating with the Redis(http://redis.io/) key-value store. Valkey(https://valkey.io/) and KeyDB(https://docs.keydb.dev/) are supported as well. + +It is released under the PHP License, version 3.01(http://www.php.net/license/3_01.txt). + +You can send comments, patches, questions here on github(https://github.com/phpredis/phpredis/issues), to Michael(mailto:michael.grunder@gmail.com) (Twitter(https://twitter.com/grumi78), <a rel="me" href="https://phpc.social/@mgrunder">Mastodon</a>), Pavlo(mailto:p.yatsukhnenko@gmail.com) (@yatsukhnenko(https://twitter.com/yatsukhnenko)), or Nicolas(mailto:n.favrefelix@gmail.com) (@yowgi(https://twitter.com/yowgi)). + +## Sponsors + +<div align="center"> + <br> + <a href="https://relay.so"> + <img src="https://s3.us-east-1.amazonaws.com/assets.relay.so/img/wordmark-purple.svg" align="center" alt="The next-generation caching layer for PHP." width="275"> + </a> + <br><br><br> + <a href="https://objectcache.pro"><img src="https://objectcache.pro/assets/wordmark-padded.png" align="center" alt="Object Cache Pro" width="200"></a> + <a href="https://audiomack.com"><img src="https://styleguide.audiomack.com/assets/dl/inline-orange-large.png" align="center" alt="Audiomack.com" width="150"></a> + <a href="https://bluehost.com"><img src="https://upload.wikimedia.org/wikipedia/commons/2/22/Bluehost-logo.png" align="center" alt="Bluehost.com" width="150"></a> + <a href="https://openlms.net"><img src="https://support.openlms.net/hc/theming_assets/01HZPV3CVP3Y6P7G6MT14NP6V1" align="center" alt="OpenLMS.net" width="125"></a> + <br><br> +</div> + +## Become a Sponsor +PhpRedis will always be free and open source software and if you or your company has found it useful please consider supporting the project. Developing a large, complex, and performant library like PhpRedis takes a great deal of time and effort, and support is greatly appreciated! :heart: + +The ongoing development of PhpRedis is made possible thanks to the generous support of Relay(https://relay.so), which funds the vast majority of work on the project. Relay is a high-performance in-memory cache and drop-in replacement for PhpRedis, which handles millions of requests per second without breaking a sweat. + +The best way to support the project is through GitHub Sponsors(https://github.com/sponsors/michael-grunder). Many of the reward tiers grant access to our Slack(https://phpredis.slack.com) where myself(https://github.com/michael-grunder) and Pavlo(https://github.com/yatsukhnenko) are regularly available to answer questions. Additionally this will allow you to provide feedback on which fixes and features to prioritize. You can also make a one-time contribution with PayPal(https://www.paypal.me/michaelgrunder/5). + +## Table of contents +1. Installing/Configuring(#installingconfiguring) + * Installation(#installation) + * PHP Session handler(#php-session-handler) + * Distributed Redis Array(./arrays.md#readme) + * Redis Cluster support(./cluster.md#readme) + * Redis Sentinel support(./sentinel.md#readme) + * Running the unit tests(#running-the-unit-tests) +2. API Documentation(#api-documentation) +3. Classes and methods(#classes-and-methods) + * Usage(#usage) + * Connection(#connection) + * Retry and backoff(#retry-and-backoff) + * Server(#server) + * Keys and strings(#keys-and-strings) + * Hashes(#hashes) + * Lists(#lists) + * Sets(#sets) + * Sorted sets(#sorted-sets) + * HyperLogLogs(#hyperloglogs) + * Geocoding(#geocoding) + * Streams(#streams) + * Pub/sub(#pubsub) + * Transactions(#transactions) + * Scripting(#scripting) + * Introspection(#introspection) + +## Installing/Configuring + +### Installation + +For everything you should need to install PhpRedis on your system, +see the INSTALL.md(./INSTALL.md) page. + +### PHP Session handler + +phpredis can be used to store PHP sessions. To do this, configure `session.save_handler` and `session.save_path` in your php.ini to tell phpredis where to store the sessions. + +`session.save_path` can have a simple `host:port` format too, but you need to provide the `tcp://` scheme if you want to use the parameters. The following parameters are available: + +* weight (integer): the weight of a host is used in comparison with the others to customize the session distribution on several hosts. If host A has twice the weight of host B, it will get twice the amount of sessions. In the example, *host1* stores 20% of all the sessions (1/(1+2+2)) while *host2* and *host3* each store 40% (2/(1+2+2)). The target host is determined once and for all at the start of the session, and doesn't change. The default weight is 1. +* timeout (float): the connection timeout to a redis host, expressed in seconds. If the host is unreachable in that amount of time, the session storage will be unavailable for the client. The default timeout is very high (86400 seconds). +* persistent (integer, should be 1 or 0): defines if a persistent connection should be used. +* prefix (string, defaults to "PHPREDIS_SESSION:"): used as a prefix to the Redis key in which the session is stored. The key is composed of the prefix followed by the session ID. +* auth (string, or an array with one or two elements): used to authenticate with the server prior to sending commands. +* database (integer): selects a different database. + +Sessions have a lifetime expressed in seconds and stored in the INI variable "session.gc_maxlifetime". You can change it with `ini_set()`(http://php.net/ini_set). +The session handler requires a version of Redis supporting `EX` and `NX` options of `SET` command (at least 2.6.12). +phpredis can also connect to a unix domain socket: `session.save_path = "unix:///var/run/redis/redis.sock?persistent=1&weight=1&database=0"`. + +#### Examples + +Multiple Redis servers: +~~~ +session.save_handler = redis +session.save_path = "tcp://host1:6379?weight=1, tcp://host2:6379?weight=2&timeout=2.5, tcp://host3:6379?weight=2&read_timeout=2.5" +~~~ + +Login to Redis using username and password: +~~~ +session.save_handler = redis +session.save_path = "tcp://127.0.0.1:6379?auth=user&auth=password" +~~~ + +Login to Redis using username, password, and set prefix: +~~~ +session.save_handler = redis +session.save_path = "tcp://127.0.0.1:6379?auth=user&auth=password&prefix=user_PHPREDIS_SESSION:" +~~~ + +#### Session locking + +**Support**: Locking feature is currently only supported for Redis setup with single master instance (e.g. classic master/slave Sentinel environment). +So locking may not work properly in RedisArray or RedisCluster environments. + +The following INI variables can be used to configure session locking: +~~~ +; Should the locking be enabled? Defaults to: 0. +redis.session.locking_enabled = 1 +; How long should the lock live (in seconds)? Defaults to: value of max_execution_time. +redis.session.lock_expire = 60 +; How long to wait between attempts to acquire lock, in microseconds (µs)?. Defaults to: 20000 +redis.session.lock_wait_time = 50000 +; Maximum number of times to retry (-1 means infinite). Defaults to: 100 +redis.session.lock_retries = 2000 +~~~ + +#### Session compression + +The following INI variables can be used to configure session compression: +~~~ +; Should session compression be enabled? Possible values are zstd, lzf, lz4, none. Defaults to: none +redis.session.compression = zstd +; What compression level should be used? Compression level depends on used library. For most deployments range 1-9 should be fine. Defaults to: 3 +redis.session.compression_level = 3 +~~~ + +### Running the unit tests + +phpredis uses a small custom unit test suite for testing functionality of the various classes. To run tests, simply do the following: + +~~~ +# Run tests for Redis class (note this is the default) +php tests/TestRedis.php --class Redis + +# Run tests for RedisArray class +tests/mkring.sh start +php tests/TestRedis.php --class RedisArray +tests/mkring.sh stop + +# Run tests for the RedisCluster class +tests/make-cluster.sh start +php tests/TestRedis.php --class RedisCluster +tests/make-cluster.sh stop + +# Run tests for RedisSentinel class +php tests/TestRedis.php --class RedisSentinel +~~~ + +Note that it is possible to run only tests which match a substring of the test itself by passing the additional argument '--test <str>' when invoking. + +~~~ +# Just run the 'echo' test +php tests/TestRedis.php --class Redis --test echo +~~~ + +## API Documentation + +The API Documentation(https://phpredis.github.io/phpredis) are a work in progress, but will eventually replace our **ONE README TO RULE THEM ALL** docs. + +## Classes and methods + +### Usage + +1. Class Redis(#class-redis) +1. Class RedisException(#class-redisexception) +1. Predefined constants(#predefined-constants) + +#### Class Redis +----- +_**Description**_: Creates a Redis client + +###### *Example* + +~~~php +$redis = new Redis(); +~~~ + +Starting from version 6.0.0 it's possible to specify configuration options. +This allows to connect lazily to the server without explicitly invoking `connect` / `pconnect`. + +###### *Example* + +~~~php +$redis = new Redis( + 'host' => '127.0.0.1', + 'port' => 6379, + 'connectTimeout' => 2.5, + 'auth' => 'phpredis', 'phpredis', + 'database' => 2, + 'ssl' => 'verify_peer' => false, + 'backoff' => + 'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER, + 'base' => 500,
View file
redis-6.3.0.tgz/redis-6.3.0/arrays.md
Changed
(renamed from redis-6.2.0/arrays.md)
View file
redis-6.3.0.tgz/redis-6.3.0/backoff.c
Changed
(renamed from redis-6.2.0/backoff.c)
View file
redis-6.3.0.tgz/redis-6.3.0/backoff.h
Changed
(renamed from redis-6.2.0/backoff.h)
View file
redis-6.3.0.tgz/redis-6.3.0/cluster.md
Changed
(renamed from redis-6.2.0/cluster.md)
View file
redis-6.3.0.tgz/redis-6.3.0/cluster_library.c
Added
@@ -0,0 +1,3274 @@ +#include "php_redis.h" +#include "common.h" +#include "library.h" +#include "redis_commands.h" +#include "cluster_library.h" +#include "crc16.h" +#include <zend_exceptions.h> + +extern zend_class_entry *redis_cluster_exception_ce; +int le_cluster_slot_cache; + +/* Debugging methods/ +static void cluster_dump_nodes(redisCluster *c) { + redisClusterNode *p; + + ZEND_HASH_FOREACH_PTR(c->nodes, p) { + if (p == NULL) { + continue; + } + + const char *slave = (p->slave) ? "slave" : "master"; + php_printf("%d %s %d %d", p->sock->port, slave,p->sock->prefix_len, + p->slot); + + php_printf("\n"); + } ZEND_HASH_FOREACH_END(); +} + +static void cluster_log(char *fmt, ...) +{ + va_list args; + char buffer1024; + + va_start(args, fmt); + vsnprintf(buffer,sizeof(buffer),fmt,args); + va_end(args); + + fprintf(stderr, "%s\n", buffer); +} + +// Debug function to dump a clusterReply structure recursively +static void dump_reply(clusterReply *reply, int indent) { + smart_string buf = {0}; + int i; + + switch(reply->type) { + case TYPE_ERR: + smart_string_appendl(&buf, "(error) ", sizeof("(error) ")-1); + smart_string_appendl(&buf, reply->str, reply->len); + break; + case TYPE_LINE: + smart_string_appendl(&buf, reply->str, reply->len); + break; + case TYPE_INT: + smart_string_appendl(&buf, "(integer) ", sizeof("(integer) ")-1); + smart_string_append_long(&buf, reply->integer); + break; + case TYPE_BULK: + smart_string_appendl(&buf,"\"", 1); + smart_string_appendl(&buf, reply->str, reply->len); + smart_string_appendl(&buf, "\"", 1); + break; + case TYPE_MULTIBULK: + if (reply->elements < 0) { + smart_string_appendl(&buf, "(nil)", sizeof("(nil)")-1); + } else { + for (i = 0; i < reply->elements; i++) { + dump_reply(reply->elementi, indent+2); + } + } + break; + default: + break; + } + + if (buf.len > 0) { + for (i = 0; i < indent; i++) { + php_printf(" "); + } + + smart_string_0(&buf); + php_printf("%s", buf.c); + php_printf("\n"); + + efree(buf.c); + } +} +*/ + +/* MULTI BULK processing callbacks */ +static int mbulk_resp_loop(RedisSock *redis_sock, zval *z_result, + long long count, void *ctx); +static int mbulk_resp_loop_raw(RedisSock *redis_sock, zval *z_result, + long long count, void *ctx); +static int mbulk_resp_loop_zipstr(RedisSock *redis_sock, zval *z_result, + long long count, void *ctx); +static int mbulk_resp_loop_dbl(RedisSock *redis_sock, zval *z_result, + long long count, void *ctx); +static int mbulk_resp_loop_zipdbl(RedisSock *redis_sock, zval *z_result, + long long count, void *ctx); +static int mbulk_resp_loop_assoc(RedisSock *redis_sock, zval *z_result, + long long count, void *ctx); + + + + +/* Recursively free our reply object. If free_data is non-zero we'll also free + * the payload data (strings) themselves. If not, we just free the structs */ +void cluster_free_reply(clusterReply *reply, int free_data) { + long long i; + + switch(reply->type) { + case TYPE_ERR: + case TYPE_LINE: + case TYPE_BULK: + if (free_data && reply->str) + efree(reply->str); + break; + case TYPE_MULTIBULK: + if (reply->element) { + if (reply->elements > 0) { + for (i = 0; i < reply->elements && reply->elementi; i++) { + cluster_free_reply(reply->elementi, free_data); + } + } + efree(reply->element); + } + break; + default: + break; + } + efree(reply); +} + +static int +cluster_multibulk_resp_recursive(RedisSock *sock, size_t elements, + clusterReply **element, int status_strings) +{ + int i; + size_t sz; + clusterReply *r; + long len; + char buf1024; + + for (i = 0; i < elements; i++) { + r = elementi = ecalloc(1, sizeof(clusterReply)); + + // Bomb out, flag error condition on a communication failure + if (redis_read_reply_type(sock, &r->type, &len) < 0) { + return FAILURE; + } + + /* Set our reply len */ + r->len = len; + + switch(r->type) { + case TYPE_ERR: + case TYPE_LINE: + if (redis_sock_gets(sock,buf,sizeof(buf),&sz) < 0) { + return FAILURE; + } + r->len = (long long)sz; + if (status_strings) r->str = estrndup(buf, r->len); + break; + case TYPE_INT: + r->integer = len; + break; + case TYPE_BULK: + if (r->len >= 0) { + r->str = redis_sock_read_bulk_reply(sock,r->len); + if (!r->str) { + return FAILURE; + } + } + break; + case TYPE_MULTIBULK: + r->elements = r->len; + if (r->elements > 0) { + r->element = ecalloc(r->len, sizeof(*r->element)); + if (cluster_multibulk_resp_recursive(sock, r->elements, r->element, status_strings) < 0) { + return FAILURE; + } + } + break; + default: + return FAILURE; + } + } + return SUCCESS; +} + +/* Return the socket for a slot and slave index */ +static RedisSock *cluster_slot_sock(redisCluster *c, unsigned short slot, + zend_ulong slaveidx) +{ + redisClusterNode *node; + + /* Return the master if we're not looking for a slave */ + if (slaveidx == 0) {
View file
redis-6.3.0.tgz/redis-6.3.0/cluster_library.h
Added
@@ -0,0 +1,531 @@ +#ifndef _PHPREDIS_CLUSTER_LIBRARY_H +#define _PHPREDIS_CLUSTER_LIBRARY_H + +#include "common.h" + +#ifdef ZTS +#include "TSRM.h" +#endif + +/* Redis cluster hash slots and N-1 which we'll use to find it */ +#define REDIS_CLUSTER_SLOTS 16384 +#define REDIS_CLUSTER_MOD (REDIS_CLUSTER_SLOTS-1) + +/* Complete representation for various commands in RESP */ +#define RESP_UNWATCH_CMD "*1\r\n$7\r\nUNWATCH\r\n" +#define RESP_CLUSTER_SLOTS_CMD "*2\r\n$7\r\nCLUSTER\r\n$5\r\nSLOTS\r\n" +#define RESP_ASKING_CMD "*1\r\n$6\r\nASKING\r\n" +#define RESP_READONLY_CMD "*1\r\n$8\r\nREADONLY\r\n" +#define RESP_READWRITE_CMD "*1\r\n$9\r\nREADWRITE\r\n" + +#define RESP_READONLY_CMD_LEN (sizeof(RESP_READONLY_CMD)-1) + +/* MOVED/ASK comparison macros */ +#define IS_MOVED(p) (p0=='M' && p1=='O' && p2=='V' && p3=='E' && \ + p4=='D' && p5==' ') +#define IS_ASK(p) (p0=='A' && p1=='S' && p2=='K' && p3==' ') + +/* MOVED/ASK lengths */ +#define MOVED_LEN (sizeof("MOVED ")-1) +#define ASK_LEN (sizeof("ASK ")-1) + +/* Initial allocation size for key distribution container */ +#define CLUSTER_KEYDIST_ALLOC 8 + +/* Macros to access nodes, sockets, and streams for a given slot */ +#define SLOT(c,s) (c->masters) +#define SLOT_SOCK(c,s) (SLOT(c,s)->sock) +#define SLOT_STREAM(c,s) (SLOT_SOCK(c,s)->stream) +#define SLOT_SLAVES(c,s) (c->masters->slaves) + +/* Compare redirection slot information with the passed node */ +#define CLUSTER_REDIR_CMP(c, sock) \ + (sock->port != c->redir_port || \ + ZSTR_LEN(sock->host) != c->redir_host_len || \ + memcmp(ZSTR_VAL(sock->host),c->redir_host,c->redir_host_len)) + +/* Clear out our "last error" */ +#define CLUSTER_CLEAR_ERROR(c) do { \ + if (c->err) { \ + zend_string_release(c->err); \ + c->err = NULL; \ + } \ + c->clusterdown = 0; \ +} while (0) + +/* Protected sending of data down the wire to a RedisSock->stream */ +#define CLUSTER_SEND_PAYLOAD(sock, buf, len) \ + (sock && !redis_sock_server_open(sock) && sock->stream && !redis_check_eof(sock, 0, 1) && \ + redis_sock_write_raw(sock, buf, len) == len) + +/* Macro to read our reply type character */ +#define CLUSTER_VALIDATE_REPLY_TYPE(sock, type) \ + (redis_check_eof(sock, 1, 1) == 0 && redis_sock_getc(sock) == type) + +/* Reset our last single line reply buffer and length */ +#define CLUSTER_CLEAR_REPLY(c) \ + *c->line_reply = '\0'; c->reply_len = 0; + +/* Helper to determine if we're in MULTI mode */ +#define CLUSTER_IS_ATOMIC(c) (c->flags->mode != MULTI) + +/* Helper that either returns false or adds false in multi mode */ +#define CLUSTER_RETURN_FALSE(c) \ + if(CLUSTER_IS_ATOMIC(c)) { \ + RETURN_FALSE; \ + } else { \ + add_next_index_bool(&c->multi_resp, 0); \ + return; \ + } + +/* Helper to either return a bool value or add it to MULTI response */ +#define CLUSTER_RETURN_BOOL(c, b) \ + if(CLUSTER_IS_ATOMIC(c)) { \ + RETURN_BOOL(b); \ + } else { \ + add_next_index_bool(&c->multi_resp, b); \ + } + +/* Helper to respond with a double or add it to our MULTI response */ +#define CLUSTER_RETURN_DOUBLE(c, d) \ + if(CLUSTER_IS_ATOMIC(c)) { \ + RETURN_DOUBLE(d); \ + } else { \ + add_next_index_double(&c->multi_resp, d); \ + } + +/* Helper to return a string value */ +#define CLUSTER_RETURN_STRING(c, str, len) \ + if(CLUSTER_IS_ATOMIC(c)) { \ + RETVAL_STRINGL(str, len); \ + } else { \ + add_next_index_stringl(&c->multi_resp, str, len); \ + } \ + +/* Return a LONG value */ +#define CLUSTER_RETURN_LONG(c, val) \ + if(CLUSTER_IS_ATOMIC(c)) { \ + RETURN_LONG(val); \ + } else { \ + add_next_index_long(&c->multi_resp, val); \ + } + +/* Macro to clear out a clusterMultiCmd structure */ +#define CLUSTER_MULTI_CLEAR(mc) \ + mc->cmd.len = 0; \ + mc->args.len = 0; \ + mc->argc = 0; \ + +/* Initialize a clusterMultiCmd with a keyword and length */ +#define CLUSTER_MULTI_INIT(mc, keyword, keyword_len) \ + 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, + REDIR_MOVED, + REDIR_ASK +} CLUSTER_REDIR_TYPE; + +/* MULTI BULK response callback typedef */ +typedef int (*mbulk_cb)(RedisSock*,zval*,long long, void*); + +/* A list of covered slot ranges */ +typedef struct redisSlotRange { + unsigned short low; + unsigned short high; +} redisSlotRange; + +/* Simple host/port information for our cache */ +typedef struct redisCachedHost { + zend_string *addr; + unsigned short port; +} redisCachedHost; + +/* Storage for a cached master node */ +typedef struct redisCachedMaster { + redisCachedHost host; + + redisSlotRange *slot; /* Slots and count */ + size_t slots; + + redisCachedHost *slave; /* Slaves and their count */ + size_t slaves; +} redisCachedMaster; + +typedef struct redisCachedCluster { + // int rsrc_id; /* Zend resource ID */ + zend_string *hash; /* What we're cached by */ + redisCachedMaster *master; /* Array of masters */ + size_t count; /* Number of masters */ +} redisCachedCluster; + +/* A Redis Cluster master node */ +typedef struct redisClusterNode { + RedisSock *sock; /* Our Redis socket in question */ + short slot; /* One slot we believe this node serves */ + zend_llist slots; /* List of all slots we believe this node serves */ + unsigned short slave; /* Are we a slave */ + HashTable *slaves; /* Hash table of slaves */ +} redisClusterNode; + +/* Forward declarations */ +typedef struct clusterFoldItem clusterFoldItem; + +/* RedisCluster implementation structure */ +typedef struct redisCluster { + + /* One RedisSock struct for serialization and prefix information */ + RedisSock *flags; + + /* How long in milliseconds should we wait when being bounced around */ + long waitms; + + /* Are we flagged as being in readonly mode, meaning we could fall back to + * a given master's slave */ + short readonly; + + /* RedisCluster failover options (never, on error, to load balance) */ + short failover; + + /* Hash table of seed host/ports */ + HashTable *seeds; + + /* RedisCluster masters, by direct slot */ + redisClusterNode *masterREDIS_CLUSTER_SLOTS; +
View file
redis-6.3.0.tgz/redis-6.3.0/common.h
Added
@@ -0,0 +1,328 @@ +#include "php.h" +#include "php_ini.h" + +#ifndef REDIS_COMMON_H +#define REDIS_COMMON_H + +#define PHPREDIS_CTX_PTR ((char *)0xDEADC0DE) +#define PHPREDIS_NOTUSED(v) ((void)v) + +#include "zend_llist.h" +#include <ext/standard/php_var.h> +#include <ext/standard/php_math.h> +#include <zend_smart_str.h> +#include <zend_smart_string.h> + +#define PHPREDIS_GET_OBJECT(class_entry, o) (class_entry *)((char *)o - XtOffsetOf(class_entry, std)) +#define PHPREDIS_ZVAL_GET_OBJECT(class_entry, z) PHPREDIS_GET_OBJECT(class_entry, Z_OBJ_P(z)) + +/* We'll fallthrough if we want to */ +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif +#if __has_attribute(__fallthrough__) +#define REDIS_FALLTHROUGH __attribute__((__fallthrough__)) +#else +#define REDIS_FALLTHROUGH do { } while (0) +#endif + +/* NULL check so Eclipse doesn't go crazy */ +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#if defined(_WIN32) || defined(_WIN64) +# define PHPREDIS_LITTLE_ENDIAN +#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) +# define PHPREDIS_BIG_ENDIAN +#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) +# define PHPREDIS_LITTLE_ENDIAN +#else +# error "Unknown endianness" +#endif + +#if defined(_MSC_VER) && !defined(__clang__) +# define REDIS_MSVC 1 +#endif + +#ifndef REDIS_MSVC +# if defined(__has_c_attribute) +# if __has_c_attribute(nodiscard) +# define REDIS_NODISCARD nodiscard +# endif +# endif +# ifndef REDIS_NODISCARD +# if defined(__has_attribute) +# if __has_attribute(warn_unused_result) +# define REDIS_NODISCARD __attribute__((warn_unused_result)) +# endif +# elif defined(__GNUC__) || defined(__clang__) +# define REDIS_NODISCARD __attribute__((warn_unused_result)) +# else +# define REDIS_NODISCARD +# endif +# endif +#else +# define REDIS_NODISCARD +#endif + +#include "backoff.h" + +typedef enum { + REDIS_SOCK_STATUS_FAILED = -1, + REDIS_SOCK_STATUS_DISCONNECTED, + REDIS_SOCK_STATUS_CONNECTED, + REDIS_SOCK_STATUS_AUTHENTICATED, + REDIS_SOCK_STATUS_READY +} redis_sock_status; + +#define _NL "\r\n" + +/* properties */ +#define REDIS_NOT_FOUND 0 +#define REDIS_STRING 1 +#define REDIS_SET 2 +#define REDIS_LIST 3 +#define REDIS_ZSET 4 +#define REDIS_HASH 5 +#define REDIS_STREAM 6 +#define REDIS_VECTORSET 7 + +#ifdef PHP_WIN32 +#define PHP_REDIS_API __declspec(dllexport) +#define phpredis_atoi64(p) _atoi64((p)) +#else +#define PHP_REDIS_API +#define phpredis_atoi64(p) atoll((p)) +#endif + +/* reply types */ +typedef enum _REDIS_REPLY_TYPE { + TYPE_EOF = -1, + TYPE_LINE = '+', + TYPE_INT = ':', + TYPE_ERR = '-', + TYPE_BULK = '$', + TYPE_MULTIBULK = '*' +} REDIS_REPLY_TYPE; + +/* SCAN variants */ +typedef enum _REDIS_SCAN_TYPE { + TYPE_SCAN, + TYPE_SSCAN, + TYPE_HSCAN, + TYPE_ZSCAN +} REDIS_SCAN_TYPE; + +/* PUBSUB subcommands */ +typedef enum _PUBSUB_TYPE { + PUBSUB_CHANNELS, + PUBSUB_NUMSUB, + PUBSUB_NUMPAT +} PUBSUB_TYPE; + +#define REDIS_SUBSCRIBE_IDX 0 +#define REDIS_PSUBSCRIBE_IDX 1 +#define REDIS_SSUBSCRIBE_IDX 2 +#define REDIS_SUBS_BUCKETS 3 + +/* options */ +#define REDIS_OPT_SERIALIZER 1 +#define REDIS_OPT_PREFIX 2 +#define REDIS_OPT_READ_TIMEOUT 3 +#define REDIS_OPT_SCAN 4 +#define REDIS_OPT_FAILOVER 5 +#define REDIS_OPT_TCP_KEEPALIVE 6 +#define REDIS_OPT_COMPRESSION 7 +#define REDIS_OPT_REPLY_LITERAL 8 +#define REDIS_OPT_COMPRESSION_LEVEL 9 +#define REDIS_OPT_NULL_MBULK_AS_NULL 10 +#define REDIS_OPT_MAX_RETRIES 11 +#define REDIS_OPT_BACKOFF_ALGORITHM 12 +#define REDIS_OPT_BACKOFF_BASE 13 +#define REDIS_OPT_BACKOFF_CAP 14 +#define REDIS_OPT_PACK_IGNORE_NUMBERS 15 + +/* cluster options */ +#define REDIS_FAILOVER_NONE 0 +#define REDIS_FAILOVER_ERROR 1 +#define REDIS_FAILOVER_DISTRIBUTE 2 +#define REDIS_FAILOVER_DISTRIBUTE_SLAVES 3 +/* serializers */ +typedef enum { + REDIS_SERIALIZER_NONE, + REDIS_SERIALIZER_PHP, + REDIS_SERIALIZER_IGBINARY, + REDIS_SERIALIZER_MSGPACK, + REDIS_SERIALIZER_JSON +} redis_serializer; +/* compression */ +#define REDIS_COMPRESSION_NONE 0 +#define REDIS_COMPRESSION_LZF 1 +#define REDIS_COMPRESSION_ZSTD 2 +#define REDIS_COMPRESSION_LZ4 3 + +/* SCAN options */ +#define REDIS_SCAN_NORETRY 0 +#define REDIS_SCAN_RETRY 1 +#define REDIS_SCAN_PREFIX 2 +#define REDIS_SCAN_NOPREFIX 3 + +/* BACKOFF_ALGORITHM options */ +#define REDIS_BACKOFF_ALGORITHMS 7 +#define REDIS_BACKOFF_ALGORITHM_DEFAULT 0 +#define REDIS_BACKOFF_ALGORITHM_DECORRELATED_JITTER 1 +#define REDIS_BACKOFF_ALGORITHM_FULL_JITTER 2 +#define REDIS_BACKOFF_ALGORITHM_EQUAL_JITTER 3 +#define REDIS_BACKOFF_ALGORITHM_EXPONENTIAL 4 +#define REDIS_BACKOFF_ALGORITHM_UNIFORM 5 +#define REDIS_BACKOFF_ALGORITHM_CONSTANT 6 + +/* GETBIT/SETBIT offset range limits */ +#define BITOP_MIN_OFFSET 0 +#define BITOP_MAX_OFFSET 4294967295U + +/* Transaction modes */ +#define ATOMIC 0 +#define MULTI 1 +#define PIPELINE 2 + +#define PHPREDIS_DEBUG_LOGGING 0 + +#if PHP_VERSION_ID < 80000 +#define Z_PARAM_ARRAY_HT_OR_NULL(dest) \ + Z_PARAM_ARRAY_HT_EX(dest, 1, 0) +#define Z_PARAM_STR_OR_NULL(dest) \ + Z_PARAM_STR_EX(dest, 1, 0) +#define Z_PARAM_ZVAL_OR_NULL(dest) \ + Z_PARAM_ZVAL_EX(dest, 1, 0) +#define Z_PARAM_BOOL_OR_NULL(dest, is_null) \
View file
redis-6.3.0.tgz/redis-6.3.0/config.m4
Changed
(renamed from redis-6.2.0/config.m4)
View file
redis-6.3.0.tgz/redis-6.3.0/config.w32
Changed
(renamed from redis-6.2.0/config.w32)
View file
redis-6.3.0.tgz/redis-6.3.0/crc16.h
Changed
(renamed from redis-6.2.0/crc16.h)
View file
redis-6.3.0.tgz/redis-6.3.0/liblzf/LICENSE
Changed
(renamed from redis-6.2.0/liblzf/LICENSE)
View file
redis-6.3.0.tgz/redis-6.3.0/liblzf/README
Changed
(renamed from redis-6.2.0/liblzf/README)
View file
redis-6.3.0.tgz/redis-6.3.0/liblzf/lzf.h
Changed
(renamed from redis-6.2.0/liblzf/lzf.h)
View file
redis-6.3.0.tgz/redis-6.3.0/liblzf/lzfP.h
Changed
(renamed from redis-6.2.0/liblzf/lzfP.h)
View file
redis-6.3.0.tgz/redis-6.3.0/liblzf/lzf_c.c
Changed
(renamed from redis-6.2.0/liblzf/lzf_c.c)
View file
redis-6.3.0.tgz/redis-6.3.0/liblzf/lzf_d.c
Changed
(renamed from redis-6.2.0/liblzf/lzf_d.c)
View file
redis-6.3.0.tgz/redis-6.3.0/library.c
Added
@@ -0,0 +1,4879 @@ +#include "php_redis.h" + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "common.h" +#include "php_network.h" +#include <sys/types.h> + +#ifdef HAVE_REDIS_IGBINARY +#include "igbinary/igbinary.h" +#endif +#ifdef HAVE_REDIS_MSGPACK +#include "msgpack/php_msgpack.h" +#endif + +#ifdef HAVE_REDIS_LZF +#include <lzf.h> + + #ifndef LZF_MARGIN + #define LZF_MARGIN 128 + #endif +#endif + +#ifdef HAVE_REDIS_ZSTD +#include <zstd.h> +#endif + +#ifdef HAVE_REDIS_LZ4 +#include <lz4.h> +#include <lz4hc.h> + +/* uint8_t crf + int length */ +#define REDIS_LZ4_HDR_SIZE (sizeof(uint8_t) + sizeof(int)) +#if defined(LZ4HC_CLEVEL_MAX) +/* version >= 1.7.5 */ +#define REDIS_LZ4_MAX_CLEVEL LZ4HC_CLEVEL_MAX + +#elif defined (LZ4HC_MAX_CLEVEL) +/* version >= 1.7.3 */ +#define REDIS_LZ4_MAX_CLEVEL LZ4HC_MAX_CLEVEL + +#else +/* older versions */ +#define REDIS_LZ4_MAX_CLEVEL 12 +#endif +#endif + +#include <zend_exceptions.h> +#include "php_redis.h" +#include "library.h" +#include "redis_commands.h" + +#ifdef HAVE_REDIS_JSON +#include <ext/json/php_json.h> +#endif + +#include <ext/hash/php_hash.h> + +#if PHP_VERSION_ID < 80400 +#include <ext/standard/php_rand.h> +#else +#include <ext/random/php_random.h> +#endif + +#define UNSERIALIZE_NONE 0 +#define UNSERIALIZE_KEYS 1 +#define UNSERIALIZE_VALS 2 +#define UNSERIALIZE_ALL 3 + +#define SCORE_DECODE_NONE 0 +#define SCORE_DECODE_INT 1 +#define SCORE_DECODE_DOUBLE 2 + +#define REDIS_CALLBACKS_INIT_SIZE 8 +#define REDIS_CALLBACKS_MAX_DOUBLE 32768 +#define REDIS_CALLBACKS_ADD_SIZE 4096 + +/* PhpRedis often returns either FALSE or NULL depending on whether we have + * an option set, so this macro just wraps that often repeated logic */ +#define REDIS_ZVAL_NULL(sock_, zv_) \ + do { \ + if ((sock_)->null_mbulk_as_null) { \ + ZVAL_NULL((zv_)); \ + } else { \ + ZVAL_FALSE((zv_)); \ + } \ + } while (0) + +/** Set return value to false in case of we are in atomic mode or add FALSE to output array in pipeline mode */ +#define REDIS_RESPONSE_ERROR(redis_sock, z_tab) \ + do { \ + if (IS_ATOMIC(redis_sock)) { \ + RETVAL_FALSE; \ + } else { \ + add_next_index_bool(z_tab, 0); \ + } \ + } while (0) + +/** Set return value to `zval` in case of we are in atomic mode or add `zval` to output array in pipeline mode */ +#define REDIS_RETURN_ZVAL(redis_sock, z_tab, zval) \ + do { \ + if (IS_ATOMIC(redis_sock)) { \ + /* Move value of `zval` to `return_value` */ \ + ZVAL_COPY_VALUE(return_value, &zval); \ + } else { \ + zend_hash_next_index_insert_new(Z_ARRVAL_P(z_tab), &zval); \ + } \ + } while (0) + +#ifndef PHP_WIN32 + #include <netinet/tcp.h> /* TCP_NODELAY */ + #include <sys/socket.h> /* SO_KEEPALIVE */ +#else + #include <winsock.h> +#endif + +extern zend_class_entry *redis_ce; +extern zend_class_entry *redis_exception_ce; + +extern int le_redis_pconnect; + +static int redis_mbulk_reply_zipped_raw_variant(RedisSock *redis_sock, zval *zret, int count); + +static int redis_bulk_resp_to_zval(RedisSock *redis_sock, zval *zdst, + int *dstlen) ; + +/* Register a persistent resource in a a way that works for every PHP 7 version. */ +void redis_register_persistent_resource(zend_string *id, void *ptr, int le_id) { + zend_register_persistent_resource(ZSTR_VAL(id), ZSTR_LEN(id), ptr, le_id); +} + +static ConnectionPool * +redis_sock_get_connection_pool(RedisSock *redis_sock) +{ + ConnectionPool *pool; + zend_resource *le; + zend_string *persistent_id; + + /* Generate our unique pool id depending on configuration */ + persistent_id = redis_pool_spprintf(redis_sock, INI_STR("redis.pconnect.pool_pattern")); + + /* Return early if we can find the pool */ + if ((le = zend_hash_find_ptr(&EG(persistent_list), persistent_id))) { + zend_string_release(persistent_id); + return le->ptr; + } + + /* Create the pool and store it in our persistent list */ + pool = pecalloc(1, sizeof(*pool), 1); + zend_llist_init(&pool->list, sizeof(php_stream *), NULL, 1); + redis_register_persistent_resource(persistent_id, pool, le_redis_pconnect); + + zend_string_release(persistent_id); + return pool; +} + +static int redis_sock_response_ok(RedisSock *redis_sock, char *buf, int buf_size) { + size_t len; + if (UNEXPECTED(redis_sock_gets(redis_sock, buf, buf_size - 1, &len) < 0)) { + return 0; + } + if (UNEXPECTED(redis_strncmp(buf, ZEND_STRL("+OK")))) { + if (buf0 == '-') { + redis_sock_set_err(redis_sock, buf + 1, len - 1); + } + return 0; + } + return 1; +} + +/* Helper to select the proper DB number */ +static int redis_select_db(RedisSock *redis_sock) { + char response4096; + smart_string cmd = {0}; + + REDIS_CMD_INIT_SSTR_STATIC(&cmd, 1, "SELECT"); + redis_cmd_append_sstr_long(&cmd, redis_sock->dbNumber); + + if (redis_sock_write(redis_sock, cmd.c, cmd.len) < 0) { + efree(cmd.c); + return -1; + } + + efree(cmd.c); + + if (!redis_sock_response_ok(redis_sock, response, sizeof(response))) { + return -1; + } + + return 0; +} + +/* Append an AUTH command to a smart string if necessary. This will either + * append the new style AUTH <user> <password>, old style AUTH <password>, or + * append no command at all. Function returns 1 if we appended a command + * and 0 otherwise. */ +static int redis_sock_append_auth(RedisSock *redis_sock, smart_string *str) {
View file
redis-6.3.0.tgz/redis-6.3.0/library.h
Added
@@ -0,0 +1,320 @@ +#ifndef REDIS_LIBRARY_H +#define REDIS_LIBRARY_H + +/* Non cluster command helper */ +#define REDIS_SPPRINTF(ret, kw, fmt, ...) \ + redis_spprintf(redis_sock, NULL, ret, kw, fmt, ##__VA_ARGS__) + +#define REDIS_CMD_APPEND_SSTR_STATIC(sstr, str) \ + redis_cmd_append_sstr(sstr, str, sizeof(str)-1); + +#define REDIS_CMD_APPEND_SSTR_OPT_STATIC(sstr, opt, str) \ + if (opt) REDIS_CMD_APPEND_SSTR_STATIC(sstr, str); + +#define REDIS_CMD_INIT_SSTR_STATIC(sstr, argc, keyword) \ + redis_cmd_init_sstr(sstr, argc, keyword, sizeof(keyword)-1); + +#define REDIS_THROW_EXCEPTION(msg, code) \ + zend_throw_exception(redis_exception_ce, (msg), code) + +#define CLUSTER_THROW_EXCEPTION(msg, code) \ + zend_throw_exception(redis_cluster_exception_ce, (msg), code) + +#define redis_sock_write_sstr(redis_sock, sstr) \ + redis_sock_write(redis_sock, (sstr)->c, (sstr)->len) + +#if PHP_VERSION_ID < 80000 + #define redis_hash_fetch_ops(zstr) php_hash_fetch_ops(ZSTR_VAL((zstr)), ZSTR_LEN((zstr))) + + /* use RedisException when ValueError not available */ + #define REDIS_VALUE_EXCEPTION(m) REDIS_THROW_EXCEPTION(m, 0) + #define RETURN_THROWS() RETURN_FALSE + /* ZVAL_STRINGL_FAST and RETVAL_STRINGL_FAST macros are supported since PHP 8 */ + #define ZVAL_STRINGL_FAST(z, s, l) ZVAL_STRINGL(z, s, l) + #define RETVAL_STRINGL_FAST(s, l) RETVAL_STRINGL(s, l) +#else + #define redis_hash_fetch_ops(zstr) php_hash_fetch_ops(zstr) + + #define REDIS_VALUE_EXCEPTION(m) zend_value_error(m) +#endif + + +void redis_register_persistent_resource(zend_string *id, void *ptr, int le_id); +fold_item* redis_add_reply_callback(RedisSock *redis_sock); +void redis_free_reply_callbacks(RedisSock *redis_sock); + +PHP_REDIS_API int redis_extract_auth_info(zval *ztest, zend_string **user, zend_string **pass); +PHP_REDIS_API void redis_with_metadata(zval *zdst, zval *zsrc, zend_long length); + +int redis_cmd_init_sstr(smart_string *str, int num_args, char *keyword, int keyword_len); +int redis_cmd_append_sstr(smart_string *str, char *append, int append_len); +int redis_cmd_append_sstr_int(smart_string *str, int append); +int redis_cmd_append_sstr_long(smart_string *str, long append); +int redis_cmd_append_sstr_zend_long(smart_string *str, zend_long append); +int redis_cmd_append_sstr_i64(smart_string *str, int64_t append); +int redis_cmd_append_sstr_u64(smart_string *str, uint64_t append); +int redis_cmd_append_sstr_dbl(smart_string *str, double value); +int redis_cmd_append_sstr_zstr(smart_string *str, zend_string *zstr); +int redis_cmd_append_sstr_zval(smart_string *str, zval *z, RedisSock *redis_sock); +int redis_cmd_append_sstr_key(smart_string *str, char *key, size_t len, RedisSock *redis_sock, short *slot); +int redis_cmd_append_sstr_key_zstr(smart_string *str, zend_string *key, RedisSock *redis_sock, short *slot); +int redis_cmd_append_sstr_key_zval(smart_string *dst, zval *zv, RedisSock *redis_sock, short *slot); +int redis_cmd_append_sstr_key_long(smart_string *dst, zend_long lval, RedisSock *redis_sock, short *slot); +int redis_cmd_append_sstr_arrkey(smart_string *cmd, zend_string *kstr, zend_ulong idx); + +PHP_REDIS_API int redis_spprintf(RedisSock *redis_sock, short *slot, char **ret, char *kw, char *fmt, ...); +PHP_REDIS_API zend_string *redis_pool_spprintf(RedisSock *redis_sock, char *fmt, ...); + +PHP_REDIS_API char *redis_sock_read(RedisSock *redis_sock, int *buf_len); +PHP_REDIS_API int redis_sock_gets(RedisSock *redis_sock, char *buf, int buf_size, size_t* line_len); +PHP_REDIS_API int redis_1_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_long_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval* z_tab, void *ctx); +typedef void (*SuccessCallback)(RedisSock *redis_sock); +PHP_REDIS_API int redis_boolean_response_impl(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx, SuccessCallback success_callback); +PHP_REDIS_API int redis_boolean_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_bulk_double_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_string_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_bulk_withmeta_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_ping_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_info_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_config_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_zrange_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API void redis_parse_info_response(char *response, zval *z_ret); +PHP_REDIS_API void redis_parse_client_list_response(char *response, zval *z_ret); +PHP_REDIS_API int redis_type_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API RedisSock* redis_sock_create(char *host, int host_len, int port, double timeout, double read_timeout, int persistent, char *persistent_id, long retry_interval); +PHP_REDIS_API int redis_sock_configure(RedisSock *redis_sock, HashTable *opts); +PHP_REDIS_API int redis_sock_connect(RedisSock *redis_sock); +PHP_REDIS_API int redis_sock_server_open(RedisSock *redis_sock); +PHP_REDIS_API int redis_sock_auth(RedisSock *redis_sock); +PHP_REDIS_API char *redis_sock_auth_cmd(RedisSock *redis_sock, int *cmdlen); +PHP_REDIS_API void redis_sock_set_auth(RedisSock *redis_sock, zend_string *user, zend_string *pass); +PHP_REDIS_API void redis_sock_set_auth_zval(RedisSock *redis_sock, zval *zv); +PHP_REDIS_API void redis_sock_free_auth(RedisSock *redis_sock); +PHP_REDIS_API int redis_sock_disconnect(RedisSock *redis_sock, int force, int is_reset_mode); +PHP_REDIS_API zval *redis_sock_read_multibulk_reply_zval(RedisSock *redis_sock, zval *z_tab); +PHP_REDIS_API char *redis_sock_read_bulk_reply(RedisSock *redis_sock, int bytes); +PHP_REDIS_API int redis_sock_read_multibulk_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *_z_tab, void *ctx); +PHP_REDIS_API void redis_mbulk_reply_loop(RedisSock *redis_sock, zval *z_tab, int count, int unserialize); + + +PHP_REDIS_API int redis_mbulk_reply_raw(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_mbulk_reply_zipped_raw(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_mbulk_reply_zipped_vals(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_mbulk_reply_zipped_keys_int(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_mbulk_reply_zipped_keys_dbl(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_mbulk_reply_assoc(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_mbulk_reply_double(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx); + +void redisSetScanCursor(zval *zv, uint64_t cursor); +uint64_t redisGetScanCursor(zval *zv, zend_bool *was_zero); + +PHP_REDIS_API int redis_sock_read_scan_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, REDIS_SCAN_TYPE type, uint64_t *cursor); + +PHP_REDIS_API int redis_xrange_reply(INTERNAL_FUNCTION_PARAMETERS, + RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_xread_reply(INTERNAL_FUNCTION_PARAMETERS, + RedisSock *redis_sock, zval *z_tab, void *ctx); + +PHP_REDIS_API int redis_xclaim_reply(INTERNAL_FUNCTION_PARAMETERS, + RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_read_xclaim_reply( + RedisSock *redis_sock, int count, int is_xautoclaim, zval *rv); + +PHP_REDIS_API int redis_xinfo_reply(INTERNAL_FUNCTION_PARAMETERS, + RedisSock *redis_sock, zval *z_tab, void *ctx); + +PHP_REDIS_API int redis_vinfo_reply(INTERNAL_FUNCTION_PARAMETERS, + RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_read_vinfo_response(RedisSock *redis_sock, + zval *z_ret, long long count); + +PHP_REDIS_API int redis_vemb_reply(INTERNAL_FUNCTION_PARAMETERS, + RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_read_vemb_response(RedisSock *redis_sock, zval *z_ret, + long long count); + +PHP_REDIS_API int redis_read_vlinks_response(RedisSock *redis_sock, zval *z_ret, + long long elements, void *ctx); +PHP_REDIS_API int redis_vlinks_reply(INTERNAL_FUNCTION_PARAMETERS, + RedisSock *redis_sock, zval *z_tab, void *ctx); + +PHP_REDIS_API int +redis_deserialize_vgetattr_reply(zval *z_ret, const char *reply, size_t len); + +PHP_REDIS_API int +redis_vgetattr_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + zval *z_tab, void *ctx); + +PHP_REDIS_API int redis_pubsub_response(INTERNAL_FUNCTION_PARAMETERS, + RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_subscribe_response(INTERNAL_FUNCTION_PARAMETERS, + RedisSock *redis_sock, zval *z_tab, void *ctx); +PHP_REDIS_API int redis_unsubscribe_response(INTERNAL_FUNCTION_PARAMETERS, + RedisSock *redis_sock, zval *z_tab, void *ctx); + +PHP_REDIS_API int redis_sock_write(RedisSock *redis_sock, char *cmd, size_t sz); +PHP_REDIS_API int redis_check_eof(RedisSock *redis_sock, zend_bool no_retry, zend_bool no_throw); +PHP_REDIS_API RedisSock *redis_sock_get(zval *id, int nothrow); +PHP_REDIS_API void redis_free_socket(RedisSock *redis_sock); +PHP_REDIS_API void redis_sock_set_err(RedisSock *redis_sock, const char *msg, int msg_len); +PHP_REDIS_API int redis_sock_set_stream_context(RedisSock *redis_sock, zval *options); +PHP_REDIS_API int redis_sock_set_backoff(RedisSock *redis_sock, zval *options); + +PHP_REDIS_API int +redis_serialize(RedisSock *redis_sock, zval *z, char **val, size_t *val_len); +PHP_REDIS_API int +redis_key_prefix(RedisSock *redis_sock, char **key, size_t *key_len); +PHP_REDIS_API zend_string* +redis_key_prefix_zval(RedisSock *redis_sock, zval *zv); +PHP_REDIS_API zend_string * +redis_key_prefix_zstr(RedisSock *redis_sock, zend_string *key); + +PHP_REDIS_API int +redis_unserialize(RedisSock *redis_sock, const char *val, int val_len, zval *z_ret); + +PHP_REDIS_API int +redis_compress(RedisSock *redis_sock, char **dst, size_t *dstlen, char *buf, size_t len); +PHP_REDIS_API int +redis_uncompress(RedisSock *redis_sock, char **dst, size_t *dstlen, const char *src, size_t len); + +PHP_REDIS_API int redis_pack(RedisSock *redis_sock, zval *z, char **val, size_t *val_len); +PHP_REDIS_API int redis_unpack(RedisSock *redis_sock, const char *val, int val_len, zval *z_ret); + +PHP_REDIS_API int +redis_read_stream_messages(RedisSock *redis_sock, int count, zval *z_ret); +PHP_REDIS_API int +redis_read_stream_messages_multi(RedisSock *redis_sock, int count, zval *z_ret); +PHP_REDIS_API int +redis_read_xinfo_response(RedisSock *redis_sock, zval *z_ret, int elements); + +PHP_REDIS_API int +redis_mpop_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + zval *z_tab, void *ctx); + +PHP_REDIS_API int +redis_read_mpop_response(RedisSock *redis_sock, zval *zdst, int elements, void *ctx); + +/* Specialized ACL reply handlers */ +PHP_REDIS_API int redis_acl_response(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab, void *ctx);
View file
redis-6.3.0.tgz/redis-6.3.0/php_redis.h
Added
@@ -0,0 +1,69 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2009 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Original author: Alfonso Jimenez <yo@alfonsojimenez.com> | + | Maintainer: Nicolas Favre-Felix <n.favre-felix@owlient.eu> | + | Maintainer: Michael Grunder <michael.grunder@gmail.com> | + | Maintainer: Nasreddine Bouafif <n.bouafif@owlient.eu> | + +----------------------------------------------------------------------+ +*/ + +#include "common.h" + +#ifndef PHP_REDIS_H +#define PHP_REDIS_H + +/* phpredis version */ +#define PHP_REDIS_VERSION "6.3.0" + +/* For convenience we store the salt as a printable hex string which requires 2 + * characters per byte + 1 for the NULL terminator */ +#define REDIS_SALT_BYTES 32 +#define REDIS_SALT_SIZE ((2 * REDIS_SALT_BYTES) + 1) + +ZEND_BEGIN_MODULE_GLOBALS(redis) + char saltREDIS_SALT_SIZE; +ZEND_END_MODULE_GLOBALS(redis) + +ZEND_EXTERN_MODULE_GLOBALS(redis) +#define REDIS_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(redis, v) + +#ifdef ZTS +#include "TSRM.h" +#endif + +PHP_MINIT_FUNCTION(redis); +PHP_MSHUTDOWN_FUNCTION(redis); +PHP_MINFO_FUNCTION(redis); + +PHP_REDIS_API int redis_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent); + +PHP_REDIS_API int redis_response_enqueued(RedisSock *redis_sock); + +PHP_REDIS_API int redis_sock_read_multibulk_multi_reply_loop( + INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab); + +extern zend_module_entry redis_module_entry; + +#define redis_module_ptr &redis_module_entry +#define phpext_redis_ptr redis_module_ptr + +#endif + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */
View file
redis-6.3.0.tgz/redis-6.3.0/redis.c
Added
@@ -0,0 +1,3300 @@ +/* -*- Mode: C; tab-width: 4 -*- */ +/* + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2009 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Original author: Alfonso Jimenez <yo@alfonsojimenez.com> | + | Maintainer: Nicolas Favre-Felix <n.favre-felix@owlient.eu> | + | Maintainer: Nasreddine Bouafif <n.bouafif@owlient.eu> | + | Maintainer: Michael Grunder <michael.grunder@gmail.com> | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php_redis.h" +#include "redis_array.h" +#include "redis_cluster.h" +#include "redis_commands.h" +#include "redis_sentinel.h" +#include <ext/spl/spl_exceptions.h> +#include <zend_exceptions.h> +#include <ext/standard/info.h> +#include <ext/hash/php_hash.h> + +#if PHP_VERSION_ID < 80400 +#include <ext/standard/php_random.h> +#else +#include <ext/random/php_random.h> +#endif + +#ifdef PHP_SESSION +#include <ext/session/php_session.h> +#endif + +#include "library.h" + +#ifdef HAVE_REDIS_ZSTD +#include <zstd.h> +#endif + +#ifdef HAVE_REDIS_LZ4 +#include <lz4.h> +#endif + +#ifdef PHP_SESSION +extern ps_module ps_mod_redis; +extern ps_module ps_mod_redis_cluster; +#endif + +zend_class_entry *redis_ce; +zend_class_entry *redis_exception_ce; + +#if PHP_VERSION_ID < 80000 +#include "redis_legacy_arginfo.h" +#else +#include "zend_attributes.h" +#include "redis_arginfo.h" +#endif + +extern const zend_function_entry *redis_get_methods(void) +{ + return class_Redis_methods; +} + +extern int le_cluster_slot_cache; +int le_redis_pconnect; + +PHP_INI_BEGIN() + /* redis arrays */ + PHP_INI_ENTRY("redis.arrays.algorithm", "", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.arrays.auth", "", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.arrays.autorehash", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.arrays.connecttimeout", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.arrays.distributor", "", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.arrays.functions", "", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.arrays.hosts", "", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.arrays.index", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.arrays.lazyconnect", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.arrays.names", "", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.arrays.pconnect", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.arrays.previous", "", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.arrays.readtimeout", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.arrays.retryinterval", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.arrays.consistent", "0", PHP_INI_ALL, NULL) + + /* redis cluster */ + PHP_INI_ENTRY("redis.clusters.cache_slots", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.clusters.auth", "", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.clusters.persistent", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.clusters.read_timeout", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.clusters.seeds", "", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.clusters.timeout", "0", PHP_INI_ALL, NULL) + + /* redis pconnect */ + PHP_INI_ENTRY("redis.pconnect.pooling_enabled", "1", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.pconnect.connection_limit", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.pconnect.echo_check_liveness", "1", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.pconnect.pool_detect_dirty", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.pconnect.pool_poll_timeout", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.pconnect.pool_pattern", "", PHP_INI_ALL, NULL) + + /* redis session */ + PHP_INI_ENTRY("redis.session.locking_enabled", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.session.lock_expire", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.session.lock_retries", "100", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.session.lock_wait_time", "20000", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.session.lock_failure_readonly", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.session.early_refresh", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.session.compression", "none", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("redis.session.compression_level", "3", PHP_INI_ALL, NULL) +PHP_INI_END() + +static const zend_module_dep redis_deps = { +#ifdef HAVE_REDIS_IGBINARY + ZEND_MOD_REQUIRED("igbinary") +#endif +#ifdef HAVE_REDIS_MSGPACK + ZEND_MOD_REQUIRED("msgpack") +#endif +#ifdef HAVE_REDIS_JSON + ZEND_MOD_REQUIRED("json") +#endif +#ifdef PHP_SESSION + ZEND_MOD_REQUIRED("session") +#endif + ZEND_MOD_END +}; + +ZEND_DECLARE_MODULE_GLOBALS(redis) + +zend_module_entry redis_module_entry = { + STANDARD_MODULE_HEADER_EX, + NULL, + redis_deps, + "redis", + NULL, + PHP_MINIT(redis), + NULL, + NULL, + NULL, + PHP_MINFO(redis), + PHP_REDIS_VERSION, + PHP_MODULE_GLOBALS(redis), + NULL, + NULL, + NULL, + STANDARD_MODULE_PROPERTIES_EX +}; + +#ifdef COMPILE_DL_REDIS +ZEND_GET_MODULE(redis) +#endif + +zend_object_handlers redis_object_handlers; + +/* Send a static DISCARD in case we're in MULTI mode. */ +static int +redis_send_discard(RedisSock *redis_sock) +{ + char *resp; + int resp_len, result = FAILURE; + + /* send our DISCARD command */ + if (redis_sock_write(redis_sock, ZEND_STRL(RESP_DISCARD_CMD)) >= 0 && + (resp = redis_sock_read(redis_sock,&resp_len)) != NULL) + { + /* success if we get OK */ + result = (resp_len == 3 && redis_strncmp(resp, ZEND_STRL("+OK")) == 0) ? SUCCESS:FAILURE; + + /* free our response */ + efree(resp); + } + + /* return success/failure */ + return result; +} + +/* Passthru for destroying cluster cache */ +static void cluster_cache_dtor(zend_resource *rsrc) { + if (rsrc->ptr) { + cluster_cache_free(rsrc->ptr); + } +} + +void +free_redis_object(zend_object *object) +{ + redis_object *redis = PHPREDIS_GET_OBJECT(redis_object, object); +
View file
redis-6.3.0.tgz/redis-6.3.0/redis.stub.php
Added
@@ -0,0 +1,5049 @@ +<?php + +/** + * @generate-function-entries + * @generate-legacy-arginfo + * @generate-class-entries + */ + +class Redis { + /** + * + * @var int + * @cvalue REDIS_NOT_FOUND + * + */ + public const REDIS_NOT_FOUND = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_STRING + * + */ + public const REDIS_STRING = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_SET + * + */ + public const REDIS_SET = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_LIST + * + */ + public const REDIS_LIST = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_ZSET + * + */ + public const REDIS_ZSET = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_HASH + * + */ + public const REDIS_HASH = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_STREAM + * + */ + public const REDIS_STREAM = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_VECTORSET + * + */ + public const REDIS_VECTORSET = UNKNOWN; + + /** + * + * @var int + * @cvalue ATOMIC + * + */ + public const ATOMIC = UNKNOWN; + + /** + * + * @var int + * @cvalue MULTI + * + */ + public const MULTI = UNKNOWN; + + /** + * + * @var int + * @cvalue PIPELINE + * + */ + public const PIPELINE = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_OPT_SERIALIZER + * + */ + public const OPT_SERIALIZER = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_OPT_PREFIX + * + */ + public const OPT_PREFIX = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_OPT_READ_TIMEOUT + * + */ + public const OPT_READ_TIMEOUT = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_OPT_TCP_KEEPALIVE + * + */ + public const OPT_TCP_KEEPALIVE = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_OPT_COMPRESSION + * + */ + public const OPT_COMPRESSION = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_OPT_REPLY_LITERAL + * + */ + public const OPT_REPLY_LITERAL = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_OPT_COMPRESSION_LEVEL + * + */ + public const OPT_COMPRESSION_LEVEL = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_OPT_NULL_MBULK_AS_NULL + * + */ + public const OPT_NULL_MULTIBULK_AS_NULL = UNKNOWN; + + /** + * @var int + * @cvalue REDIS_OPT_PACK_IGNORE_NUMBERS + * + * When enabled, this option tells PhpRedis to ignore purely numeric values + * when packing and unpacking data. This does not include numeric strings. + * If you want numeric strings to be ignored, typecast them to an int or float. + * + * The primary purpose of this option is to make it more ergonomic when + * setting keys that will later be incremented or decremented. + * + * Note: This option incurs a small performance penalty when reading data + * because we have to see if the data is a string representation of an int + * or float. + * + * @example + * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY); + * $redis->setOption(Redis::OPT_PACK_IGNORE_NUMBERS, true); + * + * $redis->set('answer', 32); + * + * var_dump($redis->incrBy('answer', 10)); // int(42) + * var_dump($redis->get('answer')); // int(42) + */ + public const OPT_PACK_IGNORE_NUMBERS = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_SERIALIZER_NONE + * + */ + public const SERIALIZER_NONE = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_SERIALIZER_PHP
View file
redis-6.3.0.tgz/redis-6.3.0/redis_arginfo.h
Added
@@ -0,0 +1,2273 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 358ec6a551a8da176ffa340e6f9696389b614758 */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___destruct, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis__compress, 0, 1, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis__uncompress arginfo_class_Redis__compress + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis__prefix, 0, 1, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis__serialize, 0, 1, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis__unserialize, 0, 1, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis__pack arginfo_class_Redis__serialize + +#define arginfo_class_Redis__unpack arginfo_class_Redis__unserialize + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_acl, 0, 1, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, subcmd, IS_STRING, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_append, 0, 2, Redis, MAY_BE_LONG|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_auth, 0, 1, Redis, MAY_BE_BOOL) + ZEND_ARG_TYPE_INFO(0, credentials, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_bgSave, 0, 0, Redis, MAY_BE_BOOL) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_bgrewriteaof arginfo_class_Redis_bgSave + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_waitaof, 0, 3, Redis, MAY_BE_ARRAY|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, numlocal, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, numreplicas, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_bitcount, 0, 1, Redis, MAY_BE_LONG|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, start, IS_LONG, 0, "0") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, end, IS_LONG, 0, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, bybit, _IS_BOOL, 0, "false") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_bitop, 0, 3, Redis, MAY_BE_LONG|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, operation, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, deskey, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, srckey, IS_STRING, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, other_keys, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_bitpos, 0, 2, Redis, MAY_BE_LONG|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, bit, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, start, IS_LONG, 0, "0") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, end, IS_LONG, 0, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, bybit, _IS_BOOL, 0, "false") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_blPop, 0, 2, Redis, MAY_BE_ARRAY|MAY_BE_NULL|MAY_BE_FALSE) + ZEND_ARG_TYPE_MASK(0, key_or_keys, MAY_BE_STRING|MAY_BE_ARRAY, NULL) + ZEND_ARG_TYPE_MASK(0, timeout_or_key, MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_LONG, NULL) + ZEND_ARG_VARIADIC_TYPE_INFO(0, extra_args, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_brPop arginfo_class_Redis_blPop + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_brpoplpush, 0, 3, Redis, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, src, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, dst, IS_STRING, 0) + ZEND_ARG_TYPE_MASK(0, timeout, MAY_BE_LONG|MAY_BE_DOUBLE, NULL) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_bzPopMax, 0, 2, Redis, MAY_BE_ARRAY|MAY_BE_FALSE) + ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, NULL) + ZEND_ARG_TYPE_MASK(0, timeout_or_key, MAY_BE_STRING|MAY_BE_LONG, NULL) + ZEND_ARG_VARIADIC_TYPE_INFO(0, extra_args, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_bzPopMin arginfo_class_Redis_bzPopMax + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_bzmpop, 0, 3, Redis, MAY_BE_ARRAY|MAY_BE_NULL|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0) + ZEND_ARG_TYPE_INFO(0, keys, IS_ARRAY, 0) + ZEND_ARG_TYPE_INFO(0, from, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, count, IS_LONG, 0, "1") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_zmpop, 0, 2, Redis, MAY_BE_ARRAY|MAY_BE_NULL|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, keys, IS_ARRAY, 0) + ZEND_ARG_TYPE_INFO(0, from, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, count, IS_LONG, 0, "1") +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_blmpop arginfo_class_Redis_bzmpop + +#define arginfo_class_Redis_lmpop arginfo_class_Redis_zmpop + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_clearLastError, 0, 0, _IS_BOOL, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_client, 0, 1, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, opt, IS_STRING, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_close arginfo_class_Redis_clearLastError + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_command, 0, 0, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, opt, IS_STRING, 1, "null") + ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_config, 0, 1, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, operation, IS_STRING, 0) + ZEND_ARG_TYPE_MASK(0, key_or_settings, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, value, IS_STRING, 1, "null") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_connect, 0, 1, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 0, "6379") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_DOUBLE, 0, "0") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, persistent_id, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, retry_interval, IS_LONG, 0, "0") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, read_timeout, IS_DOUBLE, 0, "0") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, context, IS_ARRAY, 1, "null") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_copy, 0, 2, Redis, MAY_BE_BOOL) + ZEND_ARG_TYPE_INFO(0, src, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, dst, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_dbSize, 0, 0, Redis, MAY_BE_LONG|MAY_BE_FALSE) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_debug, 0, 1, Redis, MAY_BE_STRING) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_decr, 0, 1, Redis, MAY_BE_LONG|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, by, IS_LONG, 0, "1") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_decrBy, 0, 2, Redis, MAY_BE_LONG|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_del, 0, 1, Redis, MAY_BE_LONG|MAY_BE_FALSE) + ZEND_ARG_TYPE_MASK(0, key, MAY_BE_ARRAY|MAY_BE_STRING, NULL) + ZEND_ARG_VARIADIC_TYPE_INFO(0, other_keys, IS_STRING, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_delifeq arginfo_class_Redis_append + +#define arginfo_class_Redis_delete arginfo_class_Redis_del + +#define arginfo_class_Redis_discard arginfo_class_Redis_bgSave + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_dump, 0, 1, Redis, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_echo, 0, 1, Redis, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, str, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_eval, 0, 1, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, script, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, args, IS_ARRAY, 0, "") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, num_keys, IS_LONG, 0, "0") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_eval_ro, 0, 1, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, script_sha, IS_STRING, 0)
View file
redis-6.3.0.tgz/redis-6.3.0/redis_array.c
Added
@@ -0,0 +1,1296 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2009 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Nicolas Favre-Felix <n.favre-felix@owlient.eu> | + | Maintainer: Michael Grunder <michael.grunder@gmail.com> | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "common.h" +#include "library.h" +#include "redis_array.h" +#include "redis_array_impl.h" + +#include <ext/standard/info.h> +#include <zend_exceptions.h> + +/* Simple macro to detect failure in a RedisArray call */ +#define RA_CALL_FAILED(rv, cmd) ( \ + (Z_TYPE_P(rv) == IS_FALSE) || \ + (Z_TYPE_P(rv) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_P(rv)) == 0) || \ + (Z_TYPE_P(rv) == IS_LONG && Z_LVAL_P(rv) == 0 && !strcasecmp(cmd, "TYPE")) \ +) + +extern zend_class_entry *redis_ce; +zend_class_entry *redis_array_ce; + +#if PHP_VERSION_ID < 80000 +#include "redis_array_legacy_arginfo.h" +#else +#include "zend_attributes.h" +#include "redis_array_arginfo.h" +#endif + +PHP_MINIT_FUNCTION(redis_array) +{ + /* RedisSentinel class */ + redis_array_ce = register_class_RedisArray(); + redis_array_ce->create_object = create_redis_array_object; + + return SUCCESS; +} + +static void +redis_array_free(RedisArray *ra) +{ + int i; + + /* continuum */ + if (ra->continuum) { + efree(ra->continuum->points); + efree(ra->continuum); + } + + /* Redis objects */ + for(i = 0; i< ra->count; i++) { + zval_dtor(&ra->redisi); + zend_string_release(ra->hostsi); + } + efree(ra->redis); + efree(ra->hosts); + + /* delete hash function */ + zval_dtor(&ra->z_fun); + + /* Distributor */ + zval_dtor(&ra->z_dist); + + /* Hashing algorithm */ + if (ra->algorithm) zend_string_release(ra->algorithm); + + /* Delete pur commands */ + zend_hash_destroy(ra->pure_cmds); + FREE_HASHTABLE(ra->pure_cmds); + + /* Free structure itself */ + efree(ra); +} + +typedef struct { + RedisArray *ra; + zend_object std; +} redis_array_object; + +zend_object_handlers redis_array_object_handlers; + +void +free_redis_array_object(zend_object *object) +{ + redis_array_object *obj = PHPREDIS_GET_OBJECT(redis_array_object, object); + + if (obj->ra) { + if (obj->ra->prev) redis_array_free(obj->ra->prev); + redis_array_free(obj->ra); + } + zend_object_std_dtor(&obj->std); +} + +zend_object * +create_redis_array_object(zend_class_entry *ce) +{ + redis_array_object *obj = ecalloc(1, sizeof(redis_array_object) + zend_object_properties_size(ce)); + + obj->ra = NULL; + + zend_object_std_init(&obj->std, ce); + object_properties_init(&obj->std, ce); + + memcpy(&redis_array_object_handlers, zend_get_std_object_handlers(), sizeof(redis_array_object_handlers)); + redis_array_object_handlers.offset = XtOffsetOf(redis_array_object, std); + redis_array_object_handlers.free_obj = free_redis_array_object; + redis_array_object_handlers.clone_obj = NULL; + obj->std.handlers = &redis_array_object_handlers; + + return &obj->std; +} + +/** + * redis_array_get + */ +PHP_REDIS_API RedisArray * +redis_array_get(zval *id) +{ + redis_array_object *obj; + + if (Z_TYPE_P(id) == IS_OBJECT) { + obj = PHPREDIS_ZVAL_GET_OBJECT(redis_array_object, id); + return obj->ra; + } + return NULL; +} + +/* {{{ proto RedisArray RedisArray::__construct() + Public constructor */ +PHP_METHOD(RedisArray, __construct) +{ + zval *z0, z_fun, z_dist, *zpData, *z_opts = NULL; + RedisArray *ra = NULL; + zend_bool b_index = 0, b_autorehash = 0, b_pconnect = 0, consistent = 0; + HashTable *hPrev = NULL, *hOpts = NULL; + zend_long l_retry_interval = 0; + zend_bool b_lazy_connect = 0; + double d_connect_timeout = 0, read_timeout = 0.0; + zend_string *algorithm = NULL, *user = NULL, *pass = NULL; + redis_array_object *obj; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|a", &z0, &z_opts) == FAILURE) { + RETURN_FALSE; + } + + /* Bail if z0 isn't a string or an array. + * Note: WRONG_PARAM_COUNT seems wrong but this is what we have been doing + * for ages so we can't really change it until the next major version. + */ + if (Z_TYPE_P(z0) != IS_ARRAY && Z_TYPE_P(z0) != IS_STRING) { +#if PHP_VERSION_ID < 80000 + WRONG_PARAM_COUNT; +#else + zend_argument_type_error(1, "must be of type string|array, %s given", zend_zval_type_name(z0)); + RETURN_THROWS(); +#endif + } + + /* If it's a string we want to load the array from ini information */ + if (Z_TYPE_P(z0) == IS_STRING) { + ra = ra_load_array(Z_STRVAL_P(z0)); + goto finish; + } + + ZVAL_NULL(&z_fun); + ZVAL_NULL(&z_dist); + + /* extract options */ + if(z_opts) { + hOpts = Z_ARRVAL_P(z_opts); + + /* extract previous ring. */ + zpData = REDIS_HASH_STR_FIND_STATIC(hOpts, "previous"); + if (zpData && Z_TYPE_P(zpData) == IS_ARRAY && zend_hash_num_elements(Z_ARRVAL_P(zpData)) > 0) { + hPrev = Z_ARRVAL_P(zpData); + } + + + REDIS_CONF_AUTH_STATIC(hOpts, "auth", &user, &pass); + REDIS_CONF_ZVAL_STATIC(hOpts, "function", &z_fun, 1, 0); + REDIS_CONF_ZVAL_STATIC(hOpts, "distributor", &z_dist, 1, 0); + REDIS_CONF_STRING_STATIC(hOpts, "algorithm", &algorithm);
View file
redis-6.3.0.tgz/redis-6.3.0/redis_array.h
Changed
(renamed from redis-6.2.0/redis_array.h)
View file
redis-6.3.0.tgz/redis-6.3.0/redis_array.stub.php
Changed
(renamed from redis-6.2.0/redis_array.stub.php)
View file
redis-6.3.0.tgz/redis-6.3.0/redis_array_arginfo.h
Changed
(renamed from redis-6.2.0/redis_array_arginfo.h)
View file
redis-6.3.0.tgz/redis-6.3.0/redis_array_impl.c
Added
@@ -0,0 +1,1221 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2009 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Nicolas Favre-Felix <n.favre-felix@owlient.eu> | + | Maintainer: Michael Grunder <michael.grunder@gmail.com> | + +----------------------------------------------------------------------+ +*/ +#include "redis_array_impl.h" +#include "php_redis.h" +#include "library.h" + +#include "php_variables.h" +#include "SAPI.h" +#include "ext/standard/url.h" +#include "ext/standard/crc32.h" +#include "ext/standard/md5.h" + +#include "ext/hash/php_hash.h" + +#define PHPREDIS_INDEX_NAME "__phpredis_array_index__" + +extern zend_class_entry *redis_ce; + +static RedisArray * +ra_load_hosts(RedisArray *ra, HashTable *hosts, zend_string *user, + zend_string *pass, long retry_interval, zend_bool b_lazy_connect) +{ + int i = 0, host_len; + char *host, *p; + short port; + zval *zpData; + redis_object *redis; + + /* init connections */ + ZEND_HASH_FOREACH_VAL(hosts, zpData) { + if (Z_TYPE_P(zpData) != IS_STRING) { + return NULL; + } + + /* default values */ + host = Z_STRVAL_P(zpData); + host_len = Z_STRLEN_P(zpData); + ra->hostsi = zend_string_init(host, host_len, 0); + port = 6379; + + if((p = strrchr(host, ':'))) { /* found port */ + host_len = p - host; + port = (short)atoi(p+1); + } else if(strchr(host,'/') != NULL) { /* unix socket */ + port = -1; + } + + /* create Redis object */ + object_init_ex(&ra->redisi, redis_ce); + redis = PHPREDIS_ZVAL_GET_OBJECT(redis_object, &ra->redisi); + + /* create socket */ + redis->sock = redis_sock_create(host, host_len, port, ra->connect_timeout, + ra->read_timeout, ra->pconnect, NULL, + retry_interval); + + redis_sock_set_auth(redis->sock, user, pass); + + if (!b_lazy_connect) { + if (redis_sock_server_open(redis->sock) < 0) { + ra->count = ++i; + return NULL; + } + } + + ra->count = ++i; + } ZEND_HASH_FOREACH_END(); + + return ra; +} + +/* List pure functions */ +void +ra_init_function_table(RedisArray *ra) +{ + ALLOC_HASHTABLE(ra->pure_cmds); + zend_hash_init(ra->pure_cmds, 0, NULL, NULL, 0); + + #define ra_add_pure_cmd(cmd) \ + zend_hash_str_add_empty_element(ra->pure_cmds, cmd, sizeof(cmd) - 1); + + ra_add_pure_cmd("EXISTS"); + ra_add_pure_cmd("GET"); + ra_add_pure_cmd("GETBIT"); + ra_add_pure_cmd("GETRANGE"); + ra_add_pure_cmd("HEXISTS"); + ra_add_pure_cmd("HGET"); + ra_add_pure_cmd("HGETALL"); + ra_add_pure_cmd("HKEYS"); + ra_add_pure_cmd("HLEN"); + ra_add_pure_cmd("HMGET"); + ra_add_pure_cmd("HVALS"); + ra_add_pure_cmd("LINDEX"); + ra_add_pure_cmd("LLEN"); + ra_add_pure_cmd("LRANGE"); + ra_add_pure_cmd("OBJECT"); + ra_add_pure_cmd("SCARD"); + ra_add_pure_cmd("SDIFF"); + ra_add_pure_cmd("SINTER"); + ra_add_pure_cmd("SISMEMBER"); + ra_add_pure_cmd("SMEMBERS"); + ra_add_pure_cmd("SRANDMEMBER"); + ra_add_pure_cmd("STRLEN"); + ra_add_pure_cmd("SUNION"); + ra_add_pure_cmd("TYPE"); + ra_add_pure_cmd("ZCARD"); + ra_add_pure_cmd("ZCOUNT"); + ra_add_pure_cmd("ZRANGE"); + ra_add_pure_cmd("ZRANK"); + ra_add_pure_cmd("ZREVRANGE"); + ra_add_pure_cmd("ZREVRANGEBYSCORE"); + ra_add_pure_cmd("ZREVRANK"); + ra_add_pure_cmd("ZSCORE"); + + #undef ra_add_pure_cmd +} + +static int +ra_find_name(const char *name) { + + const char *ini_names, *p, *next; + /* php_printf("Loading redis array with name=%s\n", name); */ + + ini_names = INI_STR("redis.arrays.names"); + for(p = ini_names; p;) { + next = strchr(p, ','); + if(next) { + if(redis_strncmp(p, name, next - p) == 0) { + return 1; + } + } else { + if(strcmp(p, name) == 0) { + return 1; + } + break; + } + p = next + 1; + } + + return 0; +} + +/* load array from INI settings */ +RedisArray *ra_load_array(const char *name) { + zval *z_data, z_tmp, z_fun, z_dist; + zval z_params_hosts; + zval z_params_prev; + RedisArray *ra = NULL; + + zend_string *algorithm = NULL, *user = NULL, *pass = NULL; + zend_bool b_index = 0, b_autorehash = 0, b_pconnect = 0, consistent = 0; + zend_long l_retry_interval = 0; + zend_bool b_lazy_connect = 0; + double d_connect_timeout = 0, read_timeout = 0.0; + HashTable *hHosts = NULL, *hPrev = NULL; + size_t name_len = strlen(name); + char *iptr; + + /* find entry */ + if(!ra_find_name(name)) + return ra; + + ZVAL_NULL(&z_fun); + ZVAL_NULL(&z_dist); + + /* find hosts */ + array_init(&z_params_hosts); + if ((iptr = INI_STR("redis.arrays.hosts")) != NULL) { + sapi_module.treat_data(PARSE_STRING, estrdup(iptr), &z_params_hosts); + if ((z_data = zend_hash_str_find(Z_ARRVAL(z_params_hosts), name, name_len)) != NULL) { + hHosts = Z_ARRVAL_P(z_data); + } + } + + /* find previous hosts */ + array_init(&z_params_prev); + if ((iptr = INI_STR("redis.arrays.previous")) != NULL) { + sapi_module.treat_data(PARSE_STRING, estrdup(iptr), &z_params_prev); + if ((z_data = zend_hash_str_find(Z_ARRVAL(z_params_prev), name, name_len)) != NULL) { + if (Z_TYPE_P(z_data) == IS_ARRAY) { + hPrev = Z_ARRVAL_P(z_data); + } + } + } +
View file
redis-6.3.0.tgz/redis-6.3.0/redis_array_impl.h
Changed
(renamed from redis-6.2.0/redis_array_impl.h)
View file
redis-6.3.0.tgz/redis-6.3.0/redis_array_legacy_arginfo.h
Changed
(renamed from redis-6.2.0/redis_array_legacy_arginfo.h)
View file
redis-6.3.0.tgz/redis-6.3.0/redis_cluster.c
Added
@@ -0,0 +1,3422 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2009 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Michael Grunder <michael.grunder@gmail.com> | + | Maintainer: Nicolas Favre-Felix <n.favre-felix@owlient.eu> | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "common.h" +#include "php_redis.h" +#include "ext/standard/info.h" +#include "crc16.h" +#include "redis_cluster.h" +#include "redis_commands.h" +#include <ext/spl/spl_exceptions.h> +#include <zend_exceptions.h> +#include "library.h" +#include <php_variables.h> +#include <SAPI.h> + +zend_class_entry *redis_cluster_ce; + +/* Exception handler */ +zend_class_entry *redis_cluster_exception_ce; + +#if PHP_VERSION_ID < 80000 +#include "redis_cluster_legacy_arginfo.h" +#else +#include "zend_attributes.h" +#include "redis_cluster_arginfo.h" +#endif + +static void +cluster_enqueue_response(redisCluster *c, short slot, cluster_cb cb, void *ctx) +{ + clusterFoldItem *item; + + item = emalloc(sizeof(clusterFoldItem)); + item->callback = cb; + item->slot = slot; + item->ctx = ctx; + item->next = NULL; + item->flags = c->flags->flags; + + if (UNEXPECTED(c->multi_head == NULL)) { + c->multi_head = item; + c->multi_curr = item; + } else { + c->multi_curr->next = item; + c->multi_curr = item; + } +} + +static void cluster_free_queue(redisCluster *c) { + clusterFoldItem *item = c->multi_head, *tmp; + + while (item) { + tmp = item->next; + efree(item); + item = tmp; + } + + c->multi_head = NULL; + c->multi_curr = NULL; +} + +static void cluster_reset_multi(redisCluster *c) { + redisClusterNode *node; + ZEND_HASH_FOREACH_PTR(c->nodes, node) { + if (node == NULL) + continue; + node->sock->watching = 0; + node->sock->mode = ATOMIC; + } ZEND_HASH_FOREACH_END(); + + c->flags->watching = 0; + c->flags->mode = ATOMIC; +} + +void +cluster_process_cmd(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, + redis_cmd_cb cmd_cb, cluster_cb resp_cb, int readonly) +{ + void *ctx = NULL; + int cmd_len; + short slot; + char *cmd; + + c->readonly = readonly && CLUSTER_IS_ATOMIC(c); + + if (cmd_cb(INTERNAL_FUNCTION_PARAM_PASSTHRU, c->flags, &cmd, &cmd_len, &slot, + &ctx) == FAILURE) + { + RETURN_FALSE; + } + + if (cluster_send_command(c, slot, cmd, cmd_len) < 0 || c->err != NULL) { + efree(cmd); + RETURN_FALSE; + } + + efree(cmd); + + if (c->flags->mode == MULTI) { + cluster_enqueue_response(c, slot, resp_cb, ctx); + RETURN_ZVAL(getThis(), 1, 0); + } + + resp_cb(INTERNAL_FUNCTION_PARAM_PASSTHRU, c, ctx); +} + +void +cluster_process_kw_cmd(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, + const char *kw, redis_kw_cmd_cb cmd_cb, cluster_cb resp_cb, + int readonly) +{ + void *ctx = NULL; + int cmd_len; + short slot; + char *cmd; + + c->readonly = readonly && CLUSTER_IS_ATOMIC(c); + + /* TODO: Update kw commands to take a const char * (and len to avoid strlen) */ + if (cmd_cb(INTERNAL_FUNCTION_PARAM_PASSTHRU, c->flags, (char*)kw, &cmd, &cmd_len, + &slot, &ctx) == FAILURE) + { + RETURN_FALSE; + } + + if (cluster_send_command(c, slot, cmd, cmd_len) < 0 || c->err != NULL) { + efree(cmd); + RETURN_FALSE; + } + + efree(cmd); + + if (c->flags->mode == MULTI) { + cluster_enqueue_response(c, slot, resp_cb, ctx); + RETURN_ZVAL(getThis(), 1, 0); + } + + resp_cb(INTERNAL_FUNCTION_PARAM_PASSTHRU, c, ctx); +} + +PHP_MINIT_FUNCTION(redis_cluster) +{ + redis_cluster_ce = register_class_RedisCluster(); + redis_cluster_ce->create_object = create_cluster_context; + + redis_cluster_exception_ce = register_class_RedisClusterException(spl_ce_RuntimeException); + + return SUCCESS; +} + +/* Handlers for RedisCluster */ +zend_object_handlers RedisCluster_handlers; + +/* Our context seeds will be a hash table with RedisSock* pointers */ +static void ht_free_seed(zval *data) { + RedisSock *redis_sock = *(RedisSock**)data; + if (redis_sock) redis_free_socket(redis_sock); +} + +/* Free redisClusterNode objects we've stored */ +static void ht_free_node(zval *data) { + redisClusterNode *node = *(redisClusterNode**)data; + cluster_free_node(node); +} + +/* Create redisCluster context */ +zend_object * create_cluster_context(zend_class_entry *class_type) { + redisCluster *cluster; + + // Allocate our actual struct + cluster = ecalloc(1, sizeof(redisCluster) + zend_object_properties_size(class_type)); + + // We're not currently subscribed anywhere + cluster->subscribed_slot = -1; + + // Allocate our RedisSock we'll use to store prefix/serialization flags + cluster->flags = ecalloc(1, sizeof(RedisSock)); + + // Allocate our hash table for seeds + ALLOC_HASHTABLE(cluster->seeds); + zend_hash_init(cluster->seeds, 0, NULL, ht_free_seed, 0);
View file
redis-6.3.0.tgz/redis-6.3.0/redis_cluster.h
Added
@@ -0,0 +1,32 @@ +#ifndef REDIS_CLUSTER_H +#define REDIS_CLUSTER_H + +#include "cluster_library.h" +#include "redis_commands.h" +#include <php.h> +#include <stddef.h> + +/* Get attached object context */ +#define GET_CONTEXT() PHPREDIS_ZVAL_GET_OBJECT(redisCluster, getThis()) + +void cluster_process_cmd(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, + redis_cmd_cb cmd_cb, cluster_cb resp_cb, int readonly); + +#define CLUSTER_PROCESS_CMD(cmdname, resp_func, readcmd) \ + cluster_process_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, GET_CONTEXT(), \ + redis_##cmdname##_cmd, resp_func, readcmd) + +void cluster_process_kw_cmd(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c, + const char *kw, redis_kw_cmd_cb cmd_cb, cluster_cb resp_cb, int readonly); + +#define CLUSTER_PROCESS_KW_CMD(kw, cmd_cb, resp_cb, readonly) \ + cluster_process_kw_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, GET_CONTEXT(), \ + kw, cmd_cb, resp_cb, readonly) + +extern zend_class_entry *redis_cluster_ce; +extern zend_class_entry *redis_cluster_exception_ce; +extern PHP_MINIT_FUNCTION(redis_cluster); +extern zend_object * create_cluster_context(zend_class_entry *class_type); +extern void free_cluster_context(zend_object *object); + +#endif
View file
redis-6.3.0.tgz/redis-6.3.0/redis_cluster.stub.php
Added
@@ -0,0 +1,1377 @@ +<?php + +/** + * @generate-function-entries + * @generate-legacy-arginfo + * @generate-class-entries + */ + +class RedisCluster { + /** + * + * @var int + * @cvalue REDIS_OPT_FAILOVER + * + */ + public const OPT_SLAVE_FAILOVER = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_FAILOVER_NONE + * + */ + public const FAILOVER_NONE = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_FAILOVER_ERROR + * + */ + public const FAILOVER_ERROR = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_FAILOVER_DISTRIBUTE + * + */ + public const FAILOVER_DISTRIBUTE = UNKNOWN; + + /** + * + * @var int + * @cvalue REDIS_FAILOVER_DISTRIBUTE_SLAVES + * + */ + public const FAILOVER_DISTRIBUTE_SLAVES = UNKNOWN; + + public function __construct(string|null $name, ?array $seeds = null, int|float $timeout = 0, int|float $read_timeout = 0, bool $persistent = false, #\SensitiveParameter mixed $auth = null, ?array $context = null); + + /** + * @see Redis::_compress() + */ + public function _compress(string $value): string; + + /** + * @see Redis::_uncompress() + */ + public function _uncompress(string $value): string; + + /** + * @see Redis::_serialize() + */ + public function _serialize(mixed $value): bool|string; + + /** + * @see Redis::_unserialize() + */ + public function _unserialize(string $value): mixed; + + /** + * @see Redis::_pack() + */ + public function _pack(mixed $value): string; + + /** + * @see Redis::_unpack() + */ + public function _unpack(string $value): mixed; + + /** + * @see Redis::_prefix() + */ + public function _prefix(string $key): bool|string; + + public function _masters(): array; + + public function _redir(): string|null; + + /** + * @see Redis::acl + */ + public function acl(string|array $key_or_address, string $subcmd, string ...$args): mixed; + + /** + * @see Redis::append() + */ + public function append(string $key, mixed $value): RedisCluster|bool|int; + + /** + * @see Redis::bgrewriteaof + */ + public function bgrewriteaof(string|array $key_or_address): RedisCluster|bool; + + public function waitaof(string|array $key_or_address, int $numlocal, + int $numreplicas, int $timeout): RedisCluster|array|false; + + /** + * @see Redis::bgsave + */ + public function bgsave(string|array $key_or_address): RedisCluster|bool; + + /** + * @see Redis::bitcount + */ + public function bitcount(string $key, int $start = 0, int $end = -1, bool $bybit = false): RedisCluster|bool|int; + + /** + * @see Redis::bitop + */ + public function bitop(string $operation, string $deskey, string $srckey, string ...$otherkeys): RedisCluster|bool|int; + + /** + * Return the position of the first bit set to 0 or 1 in a string. + * + * @see https://https://redis.io/commands/bitpos/ + * + * @param string $key The key to check (must be a string) + * @param bool $bit Whether to look for an unset (0) or set (1) bit. + * @param int $start Where in the string to start looking. + * @param int $end Where in the string to stop looking. + * @param bool $bybit If true, Redis will treat $start and $end as BIT values and not bytes, so if start + * was 0 and end was 2, Redis would only search the first two bits. + */ + public function bitpos(string $key, bool $bit, int $start = 0, int $end = -1, bool $bybit = false): RedisCluster|int|false; + + /** + * See Redis::blpop() + */ + public function blpop(string|array $key, string|float|int $timeout_or_key, mixed ...$extra_args): RedisCluster|array|null|false; + + /** + * See Redis::brpop() + */ + public function brpop(string|array $key, string|float|int $timeout_or_key, mixed ...$extra_args): RedisCluster|array|null|false; + + /** + * See Redis::brpoplpush() + */ + public function brpoplpush(string $srckey, string $deskey, int $timeout): mixed; + + /** + * Move an element from one list into another. + * + * @see Redis::lmove + */ + public function lmove(string $src, string $dst, string $wherefrom, string $whereto): Redis|string|false; + + /** + * Move an element from one list to another, blocking up to a timeout until an element is available. + * + * @see Redis::blmove + * + */ + public function blmove(string $src, string $dst, string $wherefrom, string $whereto, float $timeout): Redis|string|false; + + /** + * @see Redis::bzpopmax + */ + public function bzpopmax(string|array $key, string|int $timeout_or_key, mixed ...$extra_args): array; + + /** + * @see Redis::bzpopmin + */ + public function bzpopmin(string|array $key, string|int $timeout_or_key, mixed ...$extra_args): array; + + /** + * @see Redis::bzmpop + */ + public function bzmpop(float $timeout, array $keys, string $from, int $count = 1): RedisCluster|array|null|false; + + /** + * @see Redis::zmpop + */ + public function zmpop(array $keys, string $from, int $count = 1): RedisCluster|array|null|false; + + /** + * @see Redis::blmpop() + */ + public function blmpop(float $timeout, array $keys, string $from, int $count = 1): RedisCluster|array|null|false; + + /** + * @see Redis::lmpop() + */ + public function lmpop(array $keys, string $from, int $count = 1): RedisCluster|array|null|false; + + /** + * @see Redis::clearlasterror()
View file
redis-6.3.0.tgz/redis-6.3.0/redis_cluster_arginfo.h
Added
@@ -0,0 +1,1760 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 393dc58ed5ca0ea338fec43c4bd7b3b6c01235b5 */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 1) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, seeds, IS_ARRAY, 1, "null") + ZEND_ARG_TYPE_MASK(0, timeout, MAY_BE_LONG|MAY_BE_DOUBLE, "0") + ZEND_ARG_TYPE_MASK(0, read_timeout, MAY_BE_LONG|MAY_BE_DOUBLE, "0") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, persistent, _IS_BOOL, 0, "false") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, auth, IS_MIXED, 0, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, context, IS_ARRAY, 1, "null") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster__compress, 0, 1, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster__uncompress arginfo_class_RedisCluster__compress + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_RedisCluster__serialize, 0, 1, MAY_BE_BOOL|MAY_BE_STRING) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster__unserialize, 0, 1, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster__pack, 0, 1, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster__unpack arginfo_class_RedisCluster__unserialize + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_RedisCluster__prefix, 0, 1, MAY_BE_BOOL|MAY_BE_STRING) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster__masters, 0, 0, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster__redir, 0, 0, IS_STRING, 1) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_acl, 0, 2, IS_MIXED, 0) + ZEND_ARG_TYPE_MASK(0, key_or_address, MAY_BE_STRING|MAY_BE_ARRAY, NULL) + ZEND_ARG_TYPE_INFO(0, subcmd, IS_STRING, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_append, 0, 2, RedisCluster, MAY_BE_BOOL|MAY_BE_LONG) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_bgrewriteaof, 0, 1, RedisCluster, MAY_BE_BOOL) + ZEND_ARG_TYPE_MASK(0, key_or_address, MAY_BE_STRING|MAY_BE_ARRAY, NULL) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_waitaof, 0, 4, RedisCluster, MAY_BE_ARRAY|MAY_BE_FALSE) + ZEND_ARG_TYPE_MASK(0, key_or_address, MAY_BE_STRING|MAY_BE_ARRAY, NULL) + ZEND_ARG_TYPE_INFO(0, numlocal, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, numreplicas, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster_bgsave arginfo_class_RedisCluster_bgrewriteaof + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_bitcount, 0, 1, RedisCluster, MAY_BE_BOOL|MAY_BE_LONG) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, start, IS_LONG, 0, "0") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, end, IS_LONG, 0, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, bybit, _IS_BOOL, 0, "false") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_bitop, 0, 3, RedisCluster, MAY_BE_BOOL|MAY_BE_LONG) + ZEND_ARG_TYPE_INFO(0, operation, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, deskey, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, srckey, IS_STRING, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, otherkeys, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_bitpos, 0, 2, RedisCluster, MAY_BE_LONG|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, bit, _IS_BOOL, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, start, IS_LONG, 0, "0") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, end, IS_LONG, 0, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, bybit, _IS_BOOL, 0, "false") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_blpop, 0, 2, RedisCluster, MAY_BE_ARRAY|MAY_BE_NULL|MAY_BE_FALSE) + ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, NULL) + ZEND_ARG_TYPE_MASK(0, timeout_or_key, MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_LONG, NULL) + ZEND_ARG_VARIADIC_TYPE_INFO(0, extra_args, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster_brpop arginfo_class_RedisCluster_blpop + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_brpoplpush, 0, 3, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, srckey, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, deskey, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_lmove, 0, 4, Redis, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, src, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, dst, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, wherefrom, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, whereto, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_blmove, 0, 5, Redis, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, src, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, dst, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, wherefrom, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, whereto, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_bzpopmax, 0, 2, IS_ARRAY, 0) + ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, NULL) + ZEND_ARG_TYPE_MASK(0, timeout_or_key, MAY_BE_STRING|MAY_BE_LONG, NULL) + ZEND_ARG_VARIADIC_TYPE_INFO(0, extra_args, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster_bzpopmin arginfo_class_RedisCluster_bzpopmax + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_bzmpop, 0, 3, RedisCluster, MAY_BE_ARRAY|MAY_BE_NULL|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0) + ZEND_ARG_TYPE_INFO(0, keys, IS_ARRAY, 0) + ZEND_ARG_TYPE_INFO(0, from, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, count, IS_LONG, 0, "1") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_zmpop, 0, 2, RedisCluster, MAY_BE_ARRAY|MAY_BE_NULL|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, keys, IS_ARRAY, 0) + ZEND_ARG_TYPE_INFO(0, from, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, count, IS_LONG, 0, "1") +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster_blmpop arginfo_class_RedisCluster_bzmpop + +#define arginfo_class_RedisCluster_lmpop arginfo_class_RedisCluster_zmpop + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_clearlasterror, 0, 0, _IS_BOOL, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_RedisCluster_client, 0, 2, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_BOOL) + ZEND_ARG_TYPE_MASK(0, key_or_address, MAY_BE_STRING|MAY_BE_ARRAY, NULL) + ZEND_ARG_TYPE_INFO(0, subcommand, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, arg, IS_STRING, 1, "null") +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster_close arginfo_class_RedisCluster_clearlasterror + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_cluster, 0, 2, IS_MIXED, 0) + ZEND_ARG_TYPE_MASK(0, key_or_address, MAY_BE_STRING|MAY_BE_ARRAY, NULL) + ZEND_ARG_TYPE_INFO(0, command, IS_STRING, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, extra_args, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_command, 0, 0, IS_MIXED, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, extra_args, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_config, 0, 2, IS_MIXED, 0) + ZEND_ARG_TYPE_MASK(0, key_or_address, MAY_BE_STRING|MAY_BE_ARRAY, NULL) + ZEND_ARG_TYPE_INFO(0, subcommand, IS_STRING, 0) + ZEND_ARG_VARIADIC_TYPE_INFO(0, extra_args, IS_MIXED, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_dbsize, 0, 1, RedisCluster, MAY_BE_LONG) + ZEND_ARG_TYPE_MASK(0, key_or_address, MAY_BE_STRING|MAY_BE_ARRAY, NULL) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_copy, 0, 2, RedisCluster, MAY_BE_BOOL) + ZEND_ARG_TYPE_INFO(0, src, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, dst, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_decr, 0, 1, RedisCluster, MAY_BE_LONG|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, by, IS_LONG, 0, "1") +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_decrby, 0, 2, RedisCluster, MAY_BE_LONG|MAY_BE_FALSE) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_RedisCluster_decrbyfloat, 0, 2, IS_DOUBLE, 0) + ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_DOUBLE, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_RedisCluster_del, 0, 1, RedisCluster, MAY_BE_LONG|MAY_BE_FALSE) + ZEND_ARG_TYPE_MASK(0, key, MAY_BE_ARRAY|MAY_BE_STRING, NULL) + ZEND_ARG_VARIADIC_TYPE_INFO(0, other_keys, IS_STRING, 0) +ZEND_END_ARG_INFO()
View file
redis-6.3.0.tgz/redis-6.3.0/redis_cluster_legacy_arginfo.h
Added
@@ -0,0 +1,1584 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 393dc58ed5ca0ea338fec43c4bd7b3b6c01235b5 */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1) + ZEND_ARG_INFO(0, name) + ZEND_ARG_INFO(0, seeds) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, read_timeout) + ZEND_ARG_INFO(0, persistent) + ZEND_ARG_INFO(0, auth) + ZEND_ARG_INFO(0, context) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster__compress, 0, 0, 1) + ZEND_ARG_INFO(0, value) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster__uncompress arginfo_class_RedisCluster__compress + +#define arginfo_class_RedisCluster__serialize arginfo_class_RedisCluster__compress + +#define arginfo_class_RedisCluster__unserialize arginfo_class_RedisCluster__compress + +#define arginfo_class_RedisCluster__pack arginfo_class_RedisCluster__compress + +#define arginfo_class_RedisCluster__unpack arginfo_class_RedisCluster__compress + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster__prefix, 0, 0, 1) + ZEND_ARG_INFO(0, key) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster__masters, 0, 0, 0) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster__redir arginfo_class_RedisCluster__masters + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_acl, 0, 0, 2) + ZEND_ARG_INFO(0, key_or_address) + ZEND_ARG_INFO(0, subcmd) + ZEND_ARG_VARIADIC_INFO(0, args) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_append, 0, 0, 2) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, value) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_bgrewriteaof, 0, 0, 1) + ZEND_ARG_INFO(0, key_or_address) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_waitaof, 0, 0, 4) + ZEND_ARG_INFO(0, key_or_address) + ZEND_ARG_INFO(0, numlocal) + ZEND_ARG_INFO(0, numreplicas) + ZEND_ARG_INFO(0, timeout) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster_bgsave arginfo_class_RedisCluster_bgrewriteaof + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_bitcount, 0, 0, 1) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, start) + ZEND_ARG_INFO(0, end) + ZEND_ARG_INFO(0, bybit) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_bitop, 0, 0, 3) + ZEND_ARG_INFO(0, operation) + ZEND_ARG_INFO(0, deskey) + ZEND_ARG_INFO(0, srckey) + ZEND_ARG_VARIADIC_INFO(0, otherkeys) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_bitpos, 0, 0, 2) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, bit) + ZEND_ARG_INFO(0, start) + ZEND_ARG_INFO(0, end) + ZEND_ARG_INFO(0, bybit) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_blpop, 0, 0, 2) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, timeout_or_key) + ZEND_ARG_VARIADIC_INFO(0, extra_args) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster_brpop arginfo_class_RedisCluster_blpop + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_brpoplpush, 0, 0, 3) + ZEND_ARG_INFO(0, srckey) + ZEND_ARG_INFO(0, deskey) + ZEND_ARG_INFO(0, timeout) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_lmove, 0, 0, 4) + ZEND_ARG_INFO(0, src) + ZEND_ARG_INFO(0, dst) + ZEND_ARG_INFO(0, wherefrom) + ZEND_ARG_INFO(0, whereto) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_blmove, 0, 0, 5) + ZEND_ARG_INFO(0, src) + ZEND_ARG_INFO(0, dst) + ZEND_ARG_INFO(0, wherefrom) + ZEND_ARG_INFO(0, whereto) + ZEND_ARG_INFO(0, timeout) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster_bzpopmax arginfo_class_RedisCluster_blpop + +#define arginfo_class_RedisCluster_bzpopmin arginfo_class_RedisCluster_blpop + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_bzmpop, 0, 0, 3) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, keys) + ZEND_ARG_INFO(0, from) + ZEND_ARG_INFO(0, count) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_zmpop, 0, 0, 2) + ZEND_ARG_INFO(0, keys) + ZEND_ARG_INFO(0, from) + ZEND_ARG_INFO(0, count) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster_blmpop arginfo_class_RedisCluster_bzmpop + +#define arginfo_class_RedisCluster_lmpop arginfo_class_RedisCluster_zmpop + +#define arginfo_class_RedisCluster_clearlasterror arginfo_class_RedisCluster__masters + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_client, 0, 0, 2) + ZEND_ARG_INFO(0, key_or_address) + ZEND_ARG_INFO(0, subcommand) + ZEND_ARG_INFO(0, arg) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster_close arginfo_class_RedisCluster__masters + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_cluster, 0, 0, 2) + ZEND_ARG_INFO(0, key_or_address) + ZEND_ARG_INFO(0, command) + ZEND_ARG_VARIADIC_INFO(0, extra_args) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_command, 0, 0, 0) + ZEND_ARG_VARIADIC_INFO(0, extra_args) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_config, 0, 0, 2) + ZEND_ARG_INFO(0, key_or_address) + ZEND_ARG_INFO(0, subcommand) + ZEND_ARG_VARIADIC_INFO(0, extra_args) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster_dbsize arginfo_class_RedisCluster_bgrewriteaof + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_copy, 0, 0, 2) + ZEND_ARG_INFO(0, src) + ZEND_ARG_INFO(0, dst) + ZEND_ARG_INFO(0, options) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_decr, 0, 0, 1) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, by) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster_decrby arginfo_class_RedisCluster_append + +#define arginfo_class_RedisCluster_decrbyfloat arginfo_class_RedisCluster_append + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_del, 0, 0, 1) + ZEND_ARG_INFO(0, key) + ZEND_ARG_VARIADIC_INFO(0, other_keys) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster_delifeq arginfo_class_RedisCluster_append + +#define arginfo_class_RedisCluster_discard arginfo_class_RedisCluster__masters + +#define arginfo_class_RedisCluster_dump arginfo_class_RedisCluster__prefix + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_echo, 0, 0, 2) + ZEND_ARG_INFO(0, key_or_address) + ZEND_ARG_INFO(0, msg) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster_eval, 0, 0, 1) + ZEND_ARG_INFO(0, script) + ZEND_ARG_INFO(0, args) + ZEND_ARG_INFO(0, num_keys) +ZEND_END_ARG_INFO() + +#define arginfo_class_RedisCluster_eval_ro arginfo_class_RedisCluster_eval +
View file
redis-6.3.0.tgz/redis-6.3.0/redis_commands.c
Added
@@ -0,0 +1,7501 @@ +/* -*- Mode: C; tab-width: 4 -*- */ +/* + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2009 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Original Author: Michael Grunder <michael.grunder@gmail.com | + | Maintainer: Nicolas Favre-Felix <n.favre-felix@owlient.eu> | + +----------------------------------------------------------------------+ +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "redis_commands.h" + +#include "php_network.h" + +#ifndef PHP_WIN32 +#include <netinet/tcp.h> /* TCP_KEEPALIVE */ +#else +#include <winsock.h> +#endif + +#ifdef HAVE_REDIS_JSON +#include <ext/json/php_json.h> +#endif + +#include <zend_exceptions.h> + +/* Georadius sort type */ +typedef enum geoSortType { + SORT_NONE, + SORT_ASC, + SORT_DESC +} geoSortType; + +/* Georadius store type */ +typedef enum geoStoreType { + STORE_NONE, + STORE_COORD, + STORE_DIST +} geoStoreType; + +/* Georadius options structure */ +typedef struct geoOptions { + int withcoord; + int withdist; + int withhash; + long count; + zend_bool any; + geoSortType sort; + geoStoreType store; + zend_string *key; +} geoOptions; + +typedef struct redisLcsOptions { + zend_bool len; + zend_bool idx; + zend_long minmatchlen; + zend_bool withmatchlen; +} redisLcsOptions; + +typedef struct redisRestoreOptions { + zend_bool replace; + zend_bool absttl; + zend_long idletime; + zend_long freq; +} redisRestoreOptions; + +#define REDIS_ZCMD_HAS_DST_KEY (1 << 0) +#define REDIS_ZCMD_HAS_WITHSCORES (1 << 1) +#define REDIS_ZCMD_HAS_BY_LEX_SCORE (1 << 2) +#define REDIS_ZCMD_HAS_REV (1 << 3) +#define REDIS_ZCMD_HAS_LIMIT (1 << 4) +#define REDIS_ZCMD_INT_RANGE (1 << 5) +#define REDIS_ZCMD_HAS_AGGREGATE (1 << 6) + +/* ZRANGE, ZRANGEBYSCORE, ZRANGESTORE options */ +typedef struct redisZcmdOptions { + zend_bool withscores; + zend_bool byscore; + zend_bool bylex; + zend_bool rev; + zend_string *aggregate; + struct { + zend_bool enabled; + zend_long offset; + zend_long count; + } limit; +} redisZcmdOptions; + +/* Local passthrough macro for command construction. Given that these methods + * are generic (so they work whether the caller is Redis or RedisCluster) we + * will always have redis_sock, slot*, and */ +#define REDIS_CMD_SPPRINTF(ret, kw, fmt, ...) \ + redis_spprintf(redis_sock, slot, ret, kw, fmt, ##__VA_ARGS__) + +/* Generic commands based on method signature and what kind of things we're + * processing. Lots of Redis commands take something like key, value, or + * key, value long. Each unique signature like this is written only once */ + +/* A command that takes no arguments */ +int redis_empty_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, + void **ctx) +{ + *cmd_len = REDIS_CMD_SPPRINTF(cmd, kw, ""); + return SUCCESS; +} + +/* Helper to construct a raw command. Given that the cluster and non cluster + * versions are different (RedisCluster needs an additional argument to direct + * the command) we take the start of our array and count */ +int redis_build_raw_cmd(zval *z_args, int argc, char **cmd, int *cmd_len) +{ + smart_string cmdstr = {0}; + int i; + + /* Make sure our first argument is a string */ + if (Z_TYPE(z_args0) != IS_STRING) { + php_error_docref(NULL, E_WARNING, + "When sending a 'raw' command, the first argument must be a string!"); + return FAILURE; + } + + /* Initialize our command string */ + redis_cmd_init_sstr(&cmdstr, argc-1, Z_STRVAL(z_args0), Z_STRLEN(z_args0)); + + for (i = 1; i < argc; i++) { + switch (Z_TYPE(z_argsi)) { + case IS_STRING: + redis_cmd_append_sstr(&cmdstr, Z_STRVAL(z_argsi), + Z_STRLEN(z_argsi)); + break; + case IS_LONG: + redis_cmd_append_sstr_long(&cmdstr,Z_LVAL(z_argsi)); + break; + case IS_DOUBLE: + redis_cmd_append_sstr_dbl(&cmdstr,Z_DVAL(z_argsi)); + break; + default: + php_error_docref(NULL, E_WARNING, + "Raw command arguments must be scalar values!"); + efree(cmdstr.c); + return FAILURE; + } + } + + /* Push command and length to caller */ + *cmd = cmdstr.c; + *cmd_len = cmdstr.len; + + return SUCCESS; +} + +smart_string * +redis_build_script_cmd(smart_string *cmd, int argc, zval *z_args) +{ + int i; + zend_string *zstr; + + if (Z_TYPE(z_args0) != IS_STRING) { + return NULL; + } + // Branch based on the directive + if (zend_string_equals_literal_ci(Z_STR(z_args0), "kill")) { + // Simple SCRIPT_KILL command + REDIS_CMD_INIT_SSTR_STATIC(cmd, argc, "SCRIPT"); + redis_cmd_append_sstr(cmd, ZEND_STRL("KILL")); + } else if (zend_string_equals_literal_ci(Z_STR(z_args0), "flush")) { + // Simple SCRIPT FLUSH ASYNC | SYNC + if (argc > 1 && ( + Z_TYPE(z_args1) != IS_STRING || ( + !zend_string_equals_literal_ci(Z_STR(z_args1), "sync") && + !zend_string_equals_literal_ci(Z_STR(z_args1), "async") + ) + )) { + return NULL; + } + REDIS_CMD_INIT_SSTR_STATIC(cmd, argc, "SCRIPT"); + redis_cmd_append_sstr(cmd, ZEND_STRL("FLUSH")); + if (argc > 1) { + redis_cmd_append_sstr(cmd, Z_STRVAL(z_args1), Z_STRLEN(z_args1)); + } + } else if (zend_string_equals_literal_ci(Z_STR(z_args0), "load")) { + // Make sure we have a second argument, and it's not empty. If it is + // empty, we can just return an empty array (which is what Redis does) + if (argc < 2 || Z_TYPE(z_args1) != IS_STRING || Z_STRLEN(z_args1) < 1) { + return NULL; + }
View file
redis-6.3.0.tgz/redis-6.3.0/redis_commands.h
Added
@@ -0,0 +1,461 @@ +#ifndef REDIS_COMMANDS_H +#define REDIS_COMMANDS_H + +#include "common.h" +#include "library.h" +#include "cluster_library.h" + +/* Pick a random slot, any slot (for stuff like publish/subscribe) */ +#define CMD_RAND_SLOT(slot) \ + if(slot) *slot = rand() % REDIS_CLUSTER_MOD + +/* Macro for setting the slot if we've been asked to */ +#define CMD_SET_SLOT(slot,key,key_len) \ + if (slot) *slot = cluster_hash_key(key,key_len); + +/* Simple container so we can push subscribe context out */ +typedef struct { + zend_fcall_info fci; + zend_fcall_info_cache fci_cache; +} subscribeCallback; + +typedef struct subscribeContext { + char *kw; + int argc; + subscribeCallback cb; +} subscribeContext; + +/* Construct a raw command */ +int redis_build_raw_cmd(zval *z_args, int argc, char **cmd, int *cmd_len); + +/* Construct a script command */ +smart_string *redis_build_script_cmd(smart_string *cmd, int argc, zval *z_args); + +typedef int (*redis_cmd_cb)(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char **cmd, int *cmd_len, short *slot, void **ctx); + +typedef int (*redis_kw_cmd_cb)(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, + void **ctx); + +/* Process a command but with a specific command building function + * and keyword which is passed to us*/ +void redis_process_kw_cmd(INTERNAL_FUNCTION_PARAMETERS, const char *kw, + redis_kw_cmd_cb cmd_cb, FailableResultCallback resp_cb, + void *ctx); + +#define REDIS_PROCESS_KW_CMD(kw, cmdfunc, resp_func) \ + redis_process_kw_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU, kw, \ + cmdfunc, resp_func, NULL) + +/* Redis command generics. Many commands share common prototypes meaning that + * we can write one function to handle all of them. For example, there are + * many COMMAND key value commands, or COMMAND key commands. */ + +int redis_replicaof_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, + void **ctx); + +int redis_empty_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_opt_str_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, char *kw, + char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_str_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_key_long_val_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_key_long_str_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_kv_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_key_str_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_key_key_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_key_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_key_long_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_long_long_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_key_long_long_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_key_str_str_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_key_dbl_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_key_varval_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_key_val_arr_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_key_str_arr_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_pop_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_blocking_pop_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +/* Construct SCAN and similar commands, as well as check iterator */ +int redis_scan_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + REDIS_SCAN_TYPE type, char **cmd, int *cmd_len); + +/* ZRANGE, ZREVRANGE, ZRANGEBYSCORE, and ZREVRANGEBYSCORE callback type */ +typedef int (*zrange_cb)(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *,char**,int*,int*,short*,void**); + +int redis_zrange_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_config_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_function_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_zrandmember_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_zdiff_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_zinterunion_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_zdiffstore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_zinterunionstore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_intercard_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, + void **ctx); + +int redis_slowlog_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_lcs_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_mpop_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, char *kw, + char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_restore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_pubsub_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_subscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_unsubscribe_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_zrangebylex_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_gen_zlex_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_eval_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_fcall_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_failover_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_flush_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_xrange_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_vrange_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); + +int redis_georadius_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, + char *kw, char **cmd, int *cmd_len, short *slot, void **ctx); +
View file
redis-6.3.0.tgz/redis-6.3.0/redis_legacy_arginfo.h
Added
@@ -0,0 +1,2096 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 358ec6a551a8da176ffa340e6f9696389b614758 */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0) + ZEND_ARG_INFO(0, options) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___destruct, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis__compress, 0, 0, 1) + ZEND_ARG_INFO(0, value) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis__uncompress arginfo_class_Redis__compress + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis__prefix, 0, 0, 1) + ZEND_ARG_INFO(0, key) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis__serialize arginfo_class_Redis__compress + +#define arginfo_class_Redis__unserialize arginfo_class_Redis__compress + +#define arginfo_class_Redis__pack arginfo_class_Redis__compress + +#define arginfo_class_Redis__unpack arginfo_class_Redis__compress + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_acl, 0, 0, 1) + ZEND_ARG_INFO(0, subcmd) + ZEND_ARG_VARIADIC_INFO(0, args) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_append, 0, 0, 2) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, value) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_auth, 0, 0, 1) + ZEND_ARG_INFO(0, credentials) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_bgSave arginfo_class_Redis___destruct + +#define arginfo_class_Redis_bgrewriteaof arginfo_class_Redis___destruct + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_waitaof, 0, 0, 3) + ZEND_ARG_INFO(0, numlocal) + ZEND_ARG_INFO(0, numreplicas) + ZEND_ARG_INFO(0, timeout) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_bitcount, 0, 0, 1) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, start) + ZEND_ARG_INFO(0, end) + ZEND_ARG_INFO(0, bybit) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_bitop, 0, 0, 3) + ZEND_ARG_INFO(0, operation) + ZEND_ARG_INFO(0, deskey) + ZEND_ARG_INFO(0, srckey) + ZEND_ARG_VARIADIC_INFO(0, other_keys) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_bitpos, 0, 0, 2) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, bit) + ZEND_ARG_INFO(0, start) + ZEND_ARG_INFO(0, end) + ZEND_ARG_INFO(0, bybit) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_blPop, 0, 0, 2) + ZEND_ARG_INFO(0, key_or_keys) + ZEND_ARG_INFO(0, timeout_or_key) + ZEND_ARG_VARIADIC_INFO(0, extra_args) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_brPop arginfo_class_Redis_blPop + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_brpoplpush, 0, 0, 3) + ZEND_ARG_INFO(0, src) + ZEND_ARG_INFO(0, dst) + ZEND_ARG_INFO(0, timeout) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_bzPopMax, 0, 0, 2) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, timeout_or_key) + ZEND_ARG_VARIADIC_INFO(0, extra_args) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_bzPopMin arginfo_class_Redis_bzPopMax + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_bzmpop, 0, 0, 3) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, keys) + ZEND_ARG_INFO(0, from) + ZEND_ARG_INFO(0, count) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_zmpop, 0, 0, 2) + ZEND_ARG_INFO(0, keys) + ZEND_ARG_INFO(0, from) + ZEND_ARG_INFO(0, count) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_blmpop arginfo_class_Redis_bzmpop + +#define arginfo_class_Redis_lmpop arginfo_class_Redis_zmpop + +#define arginfo_class_Redis_clearLastError arginfo_class_Redis___destruct + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_client, 0, 0, 1) + ZEND_ARG_INFO(0, opt) + ZEND_ARG_VARIADIC_INFO(0, args) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_close arginfo_class_Redis___destruct + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_command, 0, 0, 0) + ZEND_ARG_INFO(0, opt) + ZEND_ARG_VARIADIC_INFO(0, args) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_config, 0, 0, 1) + ZEND_ARG_INFO(0, operation) + ZEND_ARG_INFO(0, key_or_settings) + ZEND_ARG_INFO(0, value) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_connect, 0, 0, 1) + ZEND_ARG_INFO(0, host) + ZEND_ARG_INFO(0, port) + ZEND_ARG_INFO(0, timeout) + ZEND_ARG_INFO(0, persistent_id) + ZEND_ARG_INFO(0, retry_interval) + ZEND_ARG_INFO(0, read_timeout) + ZEND_ARG_INFO(0, context) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_copy, 0, 0, 2) + ZEND_ARG_INFO(0, src) + ZEND_ARG_INFO(0, dst) + ZEND_ARG_INFO(0, options) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_dbSize arginfo_class_Redis___destruct + +#define arginfo_class_Redis_debug arginfo_class_Redis__prefix + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_decr, 0, 0, 1) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, by) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_decrBy arginfo_class_Redis_append + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_del, 0, 0, 1) + ZEND_ARG_INFO(0, key) + ZEND_ARG_VARIADIC_INFO(0, other_keys) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_delifeq arginfo_class_Redis_append + +#define arginfo_class_Redis_delete arginfo_class_Redis_del + +#define arginfo_class_Redis_discard arginfo_class_Redis___destruct + +#define arginfo_class_Redis_dump arginfo_class_Redis__prefix + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_echo, 0, 0, 1) + ZEND_ARG_INFO(0, str) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_eval, 0, 0, 1) + ZEND_ARG_INFO(0, script) + ZEND_ARG_INFO(0, args) + ZEND_ARG_INFO(0, num_keys) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_eval_ro, 0, 0, 1) + ZEND_ARG_INFO(0, script_sha) + ZEND_ARG_INFO(0, args) + ZEND_ARG_INFO(0, num_keys) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_evalsha, 0, 0, 1) + ZEND_ARG_INFO(0, sha1) + ZEND_ARG_INFO(0, args) + ZEND_ARG_INFO(0, num_keys) +ZEND_END_ARG_INFO() + +#define arginfo_class_Redis_evalsha_ro arginfo_class_Redis_evalsha + +#define arginfo_class_Redis_exec arginfo_class_Redis___destruct +
View file
redis-6.3.0.tgz/redis-6.3.0/redis_sentinel.c
Changed
(renamed from redis-6.2.0/redis_sentinel.c)
View file
redis-6.3.0.tgz/redis-6.3.0/redis_sentinel.h
Changed
(renamed from redis-6.2.0/redis_sentinel.h)
View file
redis-6.3.0.tgz/redis-6.3.0/redis_sentinel.stub.php
Changed
(renamed from redis-6.2.0/redis_sentinel.stub.php)
View file
redis-6.3.0.tgz/redis-6.3.0/redis_sentinel_arginfo.h
Changed
(renamed from redis-6.2.0/redis_sentinel_arginfo.h)
View file
redis-6.3.0.tgz/redis-6.3.0/redis_sentinel_legacy_arginfo.h
Changed
(renamed from redis-6.2.0/redis_sentinel_legacy_arginfo.h)
View file
redis-6.3.0.tgz/redis-6.3.0/redis_session.c
Added
@@ -0,0 +1,1388 @@ +/* -*- Mode: C; tab-width: 4 -*- */ +/* + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2009 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Original author: Alfonso Jimenez <yo@alfonsojimenez.com> | + | Maintainer: Nicolas Favre-Felix <n.favre-felix@owlient.eu> | + | Maintainer: Nasreddine Bouafif <n.bouafif@owlient.eu> | + | Maintainer: Michael Grunder <michael.grunder@gmail.com> | + +----------------------------------------------------------------------+ +*/ + +#include "common.h" + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef PHP_SESSION +#include "ext/standard/info.h" +#include "php_redis.h" +#include "redis_session.h" +#include <zend_exceptions.h> + +#include "library.h" +#include "cluster_library.h" + +#include "php.h" +#include "php_ini.h" +#include "php_variables.h" +#include "SAPI.h" +#include "ext/standard/url.h" + +#define REDIS_SESSION_PREFIX "PHPREDIS_SESSION:" +#define CLUSTER_SESSION_PREFIX "PHPREDIS_CLUSTER_SESSION:" + +/* Session lock LUA as well as its SHA1 hash */ +#define LOCK_RELEASE_LUA_STR "if redis.call(\"get\",KEYS1) == ARGV1 then return redis.call(\"del\",KEYS1) else return 0 end" +#define LOCK_RELEASE_LUA_LEN (sizeof(LOCK_RELEASE_LUA_STR) - 1) +#define LOCK_RELEASE_SHA_STR "b70c2384248f88e6b75b9f89241a180f856ad852" +#define LOCK_RELEASE_SHA_LEN (sizeof(LOCK_RELEASE_SHA_STR) - 1) + +/* Check if a response is the Redis +OK status response */ +#define IS_REDIS_OK(r, len) (r != NULL && len == 3 && !memcmp(r, "+OK", 3)) +#define NEGATIVE_LOCK_RESPONSE 1 + +#define CLUSTER_DEFAULT_PREFIX() \ + zend_string_init(CLUSTER_SESSION_PREFIX, sizeof(CLUSTER_SESSION_PREFIX) - 1, 0) + +ps_module ps_mod_redis = { + PS_MOD_UPDATE_TIMESTAMP(redis) +}; + +ps_module ps_mod_redis_cluster = { + PS_MOD_UPDATE_TIMESTAMP(rediscluster) +}; + +typedef struct { + zend_bool is_locked; + zend_string *session_key; + zend_string *lock_key; + zend_string *lock_secret; +} redis_session_lock_status; + +typedef struct redis_pool_member_ { + + RedisSock *redis_sock; + int weight; + struct redis_pool_member_ *next; + +} redis_pool_member; + +typedef struct { + + int totalWeight; + int count; + + redis_pool_member *head; + redis_session_lock_status lock_status; + +} redis_pool; + +// static char *session_conf_string(HashTable *ht, const char *key, size_t keylen) { +// } + +PHP_REDIS_API void +redis_pool_add(redis_pool *pool, RedisSock *redis_sock, int weight) +{ + redis_pool_member *rpm = ecalloc(1, sizeof(redis_pool_member)); + rpm->redis_sock = redis_sock; + rpm->weight = weight; + + rpm->next = pool->head; + pool->head = rpm; + + pool->totalWeight += weight; +} + +PHP_REDIS_API void +redis_pool_free(redis_pool *pool) { + + redis_pool_member *rpm, *next; + + if (pool == NULL) + return; + + rpm = pool->head; + while (rpm) { + next = rpm->next; + redis_sock_disconnect(rpm->redis_sock, 0, 1); + redis_free_socket(rpm->redis_sock); + efree(rpm); + rpm = next; + } + + /* Cleanup after our lock */ + if (pool->lock_status.session_key) zend_string_release(pool->lock_status.session_key); + if (pool->lock_status.lock_secret) zend_string_release(pool->lock_status.lock_secret); + if (pool->lock_status.lock_key) zend_string_release(pool->lock_status.lock_key); + + /* Cleanup pool itself */ + efree(pool); +} + +/* Retrieve session.gc_maxlifetime from php.ini protecting against an integer overflow */ +static int session_gc_maxlifetime(void) { + zend_long value = INI_INT("session.gc_maxlifetime"); + if (value > INT_MAX) { + php_error_docref(NULL, E_NOTICE, "session.gc_maxlifetime overflows INT_MAX, truncating."); + return INT_MAX; + } else if (value <= 0) { + php_error_docref(NULL, E_NOTICE, "session.gc_maxlifetime is <= 0, defaulting to 1440 seconds"); + return 1440; + } + + return value; +} + +/* Retrieve redis.session.compression from php.ini */ +static int session_compression_type(void) { + const char *compression = INI_STR("redis.session.compression"); + if(compression == NULL || *compression == '\0' || strncasecmp(compression, "none", sizeof("none") - 1) == 0) { + return REDIS_COMPRESSION_NONE; + } + +#ifdef HAVE_REDIS_LZF + if(strncasecmp(compression, "lzf", sizeof("lzf") - 1) == 0) { + return REDIS_COMPRESSION_LZF; + } +#endif +#ifdef HAVE_REDIS_ZSTD + if(strncasecmp(compression, "zstd", sizeof("zstd") - 1) == 0) { + return REDIS_COMPRESSION_ZSTD; + } +#endif +#ifdef HAVE_REDIS_LZ4 + if(strncasecmp(compression, "lz4", sizeof("lz4") - 1) == 0) { + return REDIS_COMPRESSION_LZ4; + } +#endif + + // E_NOTICE when outside of valid values + php_error_docref(NULL, E_NOTICE, "redis.session.compression is outside of valid values, disabling"); + + return REDIS_COMPRESSION_NONE; +} + +/* Helper to compress session data */ +static int +session_compress_data(RedisSock *redis_sock, char *data, size_t len, + char **compressed_data, size_t *compressed_len) +{ + if (redis_sock->compression) { + if(redis_compress(redis_sock, compressed_data, compressed_len, data, len)) { + return 1; + } + } + + *compressed_data = data; + *compressed_len = len; + + return 0; +} + +/* Helper to uncompress session data */ +static int +session_uncompress_data(RedisSock *redis_sock, char *data, size_t len, + char **decompressed_data, size_t *decompressed_len) { + if (redis_sock->compression) { + if(redis_uncompress(redis_sock, decompressed_data, decompressed_len, data, len)) { + return 1;
View file
redis-6.3.0.tgz/redis-6.3.0/redis_session.h
Changed
(renamed from redis-6.2.0/redis_session.h)
View file
redis-6.3.0.tgz/redis-6.3.0/sentinel.md
Changed
(renamed from redis-6.2.0/sentinel.md)
View file
redis-6.3.0.tgz/redis-6.3.0/sentinel_library.c
Changed
(renamed from redis-6.2.0/sentinel_library.c)
View file
redis-6.3.0.tgz/redis-6.3.0/sentinel_library.h
Changed
(renamed from redis-6.2.0/sentinel_library.h)
View file
redis-6.3.0.tgz/redis-6.3.0/tests/RedisArrayTest.php
Changed
(renamed from redis-6.2.0/tests/RedisArrayTest.php)
View file
redis-6.3.0.tgz/redis-6.3.0/tests/RedisClusterTest.php
Added
@@ -0,0 +1,921 @@ +<?php defined('PHPREDIS_TESTRUN') or die("Use TestRedis.php to run tests!\n"); + +require_once __DIR__ . "/RedisTest.php"; + +/** + * Most RedisCluster tests should work the same as the standard Redis object + * so we only override specific functions where the prototype is different or + * where we're validating specific cluster mechanisms + */ +class Redis_Cluster_Test extends Redis_Test { + private $redis_types = + Redis::REDIS_STRING, + Redis::REDIS_SET, + Redis::REDIS_LIST, + Redis::REDIS_ZSET, + Redis::REDIS_HASH + ; + + private $failover_types = + RedisCluster::FAILOVER_NONE, + RedisCluster::FAILOVER_ERROR, + RedisCluster::FAILOVER_DISTRIBUTE + ; + + protected static array $seeds = ; + + private static array $seed_messages = ; + private static string $seed_source = ''; + + public function testServerInfo() { $this->markTestSkipped(); } + public function testServerInfoOldRedis() { $this->markTestSkipped(); } + + /* Tests we'll skip all together in the context of RedisCluster. The + * RedisCluster class doesn't implement specialized (non-redis) commands + * such as sortAsc, or sortDesc and other commands such as SELECT are + * simply invalid in Redis Cluster */ + public function testPipelinePublish() { $this->markTestSkipped(); } + public function testSortAsc() { $this->markTestSkipped(); } + public function testSortDesc() { $this->markTestSkipped(); } + public function testWait() { $this->markTestSkipped(); } + public function testSelect() { $this->markTestSkipped(); } + public function testReconnectSelect() { $this->markTestSkipped(); } + public function testMultipleConnect() { $this->markTestSkipped(); } + public function testDoublePipeNoOp() { $this->markTestSkipped(); } + public function testSwapDB() { $this->markTestSkipped(); } + public function testConnectException() { $this->markTestSkipped(); } + public function testTlsConnect() { $this->markTestSkipped(); } + public function testReset() { $this->markTestSkipped(); } + public function testInvalidAuthArgs() { $this->markTestSkipped(); } + public function testScanErrors() { $this->markTestSkipped(); } + public function testConnectDatabaseSelect() { $this->markTestSkipped(); } + + /* These 'directed node' commands work differently in RedisCluster */ + public function testConfig() { $this->markTestSkipped(); } + public function testFlushDB() { $this->markTestSkipped(); } + public function testFunction() { $this->markTestSkipped(); } + + /* Session locking feature is currently not supported in in context of Redis Cluster. + The biggest issue for this is the distribution nature of Redis cluster */ + public function testSession_lockKeyCorrect() { $this->markTestSkipped(); } + public function testSession_lockingDisabledByDefault() { $this->markTestSkipped(); } + public function testSession_lockReleasedOnClose() { $this->markTestSkipped(); } + public function testSession_ttlMaxExecutionTime() { $this->markTestSkipped(); } + public function testSession_ttlLockExpire() { $this->markTestSkipped(); } + public function testSession_lockHoldCheckBeforeWrite_otherProcessHasLock() { $this->markTestSkipped(); } + public function testSession_lockHoldCheckBeforeWrite_nobodyHasLock() { $this->markTestSkipped(); } + public function testSession_correctLockRetryCount() { $this->markTestSkipped(); } + public function testSession_defaultLockRetryCount() { $this->markTestSkipped(); } + public function testSession_noUnlockOfOtherProcess() { $this->markTestSkipped(); } + public function testSession_lockWaitTime() { $this->markTestSkipped(); } + + private function loadSeedsFromHostPort($host, $port) { + try { + $rc = new RedisCluster(NULL, "$host:$port", 1, 1, true, $this->getAuth()); + self::$seed_source = "Host: $host, Port: $port"; + return array_map(function($master) { + return sprintf('%s:%s', $master0, $master1); + }, $rc->_masters()); + } catch (Exception $ex) { + /* fallthrough */ + } + + self::$seed_messages = "--host=$host, --port=$port"; + + return false; + } + + private function loadSeedsFromEnv() { + $seeds = getenv('REDIS_CLUSTER_NODES'); + if ( ! $seeds) { + self::$seed_messages = "environment variable REDIS_CLUSTER_NODES ($seeds)"; + return false; + } + + self::$seed_source = 'Environment variable REDIS_CLUSTER_NODES'; + return array_filter(explode(' ', $seeds)); + } + + private function loadSeedsFromNodeMap() { + $nodemap_file = dirname($_SERVER'PHP_SELF') . '/nodes/nodemap'; + if ( ! file_exists($nodemap_file)) { + self::$seed_messages = "nodemap file '$nodemap_file'"; + return false; + } + + self::$seed_source = "Nodemap file '$nodemap_file'"; + return array_filter(explode("\n", file_get_contents($nodemap_file))); + } + + private function loadSeeds($host, $port) { + if (($seeds = $this->loadSeedsFromNodeMap())) + return $seeds; + if (($seeds = $this->loadSeedsFromEnv())) + return $seeds; + if (($seeds = $this->loadSeedsFromHostPort($host, $port))) + return $seeds; + + TestSuite::errorMessage("Error: Unable to load seeds for RedisCluster tests"); + foreach (self::$seed_messages as $msg) { + TestSuite::errorMessage(" Tried: %s", $msg); + } + + exit(1); + } + + /* Load our seeds on construction */ + public function __construct($host, $port, $auth) { + parent::__construct($host, $port, $auth); + + self::$seeds = $this->loadSeeds($host, $port); + } + + /* Override setUp to get info from a specific node */ + public function setUp() { + $this->redis = $this->newInstance(); + $info = $this->redis->info(uniqid()); + $this->version = $info'redis_version' ?? '0.0.0'; + $this->is_keydb = $this->detectKeyDB($info); + $this->is_valkey = $this->detectValkey($info); + $this->valkey_version = $info'valkey_version' ?? '0.0.0'; + } + + private function findCliExe() { + foreach ('redis-cli', 'valkey-cli' as $candidate) { + $path = trim(shell_exec("command -v $candidate 2>/dev/null")); + if (is_executable($path)) { + return $path; + } + } + + return NULL; + } + + private function getServerReply($host, $port, $cmd) { + $cli = $this->findCliExe(); + if ( ! $cli) { + return '(no redis-cli or valkey-cli found)'; + } + + $args = $cli, '-h', $host, '-p', $port; + + $this->getAuthParts($user, $pass); + + if ($user) $args = array_merge($args, '--user', $user); + if ($pass) $args = array_merge($args, '-a', $pass); + + $resp = shell_exec(implode(' ', $args) . ' ' . $cmd . ' 2>/dev/null'); + + return is_string($resp) ? trim($resp) : $resp; + } + + /* Try to gat a new RedisCluster instance. The strange logic is an attempt + to solve a problem where this sometimes fails but only ever on GitHub + runners. If we're not on a runner we just get a new instance. Otherwise + we allow for two tries to get the instance. */ + private function getNewInstance() { + if (getenv('GITHUB_ACTIONS') === 'true') { + try { + return new RedisCluster(NULL, self::$seeds, 30, 30, true, + $this->getAuth()); + } catch (Exception $ex) { + TestSuite::errorMessage("Failed to connect: %s", $ex->getMessage()); + } + } + + return new RedisCluster(NULL, self::$seeds, 30, 30, true, $this->getAuth()); + } + + /* Override newInstance as we want a RedisCluster object */ + protected function newInstance() { + try { + return $this->getNewInstance(); + } catch (Exception $ex) { + TestSuite::errorMessage(""); + TestSuite::errorMessage("Fatal error: %s", $ex->getMessage()); + TestSuite::errorMessage("Seeds: %s", implode(' ', self::$seeds)); + TestSuite::errorMessage("Seed source: %s", self::$seed_source); + TestSuite::errorMessage(""); +
View file
redis-6.3.0.tgz/redis-6.3.0/tests/RedisSentinelTest.php
Added
@@ -0,0 +1,160 @@ +<?php defined('PHPREDIS_TESTRUN') or die("Use TestRedis.php to run tests!\n"); + +require_once __DIR__ . "/TestSuite.php"; + +class Redis_Sentinel_Test extends TestSuite +{ + const NAME = 'mymaster'; + + /** + * @var RedisSentinel + */ + public $sentinel; + + /** + * Common fields + */ + protected $fields = + 'name', + 'ip', + 'port', + 'runid', + 'flags', + 'link-pending-commands', + 'link-refcount', + 'last-ping-sent', + 'last-ok-ping-reply', + 'last-ping-reply', + 'down-after-milliseconds', + ; + + protected function newInstance() + { + return new RedisSentinel('host' => $this->getHost()); + } + + public function setUp() + { + $this->sentinel = $this->newInstance(); + } + + public function testCkquorum() + { + $this->assertTrue($this->sentinel->ckquorum(self::NAME)); + } + + public function testFailover() + { + $this->assertFalse($this->sentinel->failover(self::NAME)); + } + + public function testFlushconfig() + { + $this->assertTrue($this->sentinel->flushconfig()); + } + + public function testGetMasterAddrByName() + { + $result = $this->sentinel->getMasterAddrByName(self::NAME); + $this->assertTrue(is_array($result)); + $this->assertEquals(2, count($result)); + } + + protected function checkFields(array $fields) + { + foreach ($this->fields as $k) { + $this->assertTrue(array_key_exists($k, $fields)); + } + } + + public function testMaster() + { + $result = $this->sentinel->master(self::NAME); + $this->assertTrue(is_array($result)); + $this->checkFields($result); + } + + public function testMasters() + { + $result = $this->sentinel->masters(); + $this->assertTrue(is_array($result)); + foreach ($result as $master) { + $this->checkFields($master); + } + } + + public function testMyid() + { + $result = $this->sentinel->myid(); + $this->assertTrue(is_string($result)); + } + + public function testPing() + { + $this->assertTrue($this->sentinel->ping()); + } + + public function testReset() + { + $this->assertEquals(1, $this->sentinel->reset('*')); + } + + public function testSentinels() + { + $result = $this->sentinel->sentinels(self::NAME); + $this->assertTrue(is_array($result)); + foreach ($result as $sentinel) { + $this->checkFields($sentinel); + } + } + + public function testSlaves() + { + $result = $this->sentinel->slaves(self::NAME); + $this->assertTrue(is_array($result)); + foreach ($result as $slave) { + $this->checkFields($slave); + } + } + + protected function getClients(Redis $redis, string $cmd) + { + $result = ; + + foreach ($redis->client('list') as $client) { + if ($client'cmd' !== $cmd) + continue; + + $result = $client'id'; + } + + return $result; + } + + public function testPersistent() { + /* I think the tests just use the default port */ + $redis = new Redis; + $redis->connect($this->getHost(), 26379); + + $id = null; + + for ($i = 0; $i < 3; $i++) { + $sentinel = new RedisSentinel( + 'host' => $this->getHost(), + 'persistent' => 'sentinel', + ); + + $this->assertTrue($sentinel->ping()); + + $clients = $this->getClients($redis, 'ping'); + + /* Capture the ping client */ + $id ??= $clients0; + + unset($sentinel); + } + + /* The same client should have been reused */ + $this->assertEquals($id, $clients0); + } +}
View file
redis-6.3.0.tgz/redis-6.3.0/tests/RedisTest.php
Added
@@ -0,0 +1,8683 @@ +<?php defined('PHPREDIS_TESTRUN') or die('Use TestRedis.php to run tests!\n'); + +require_once __DIR__ . '/TestSuite.php'; +require_once __DIR__ . '/SessionHelpers.php'; + +class Redis_Test extends TestSuite { + /** + * @var Redis + */ + public $redis; + + /* City lat/long */ + protected $cities = + 'Chico' => -121.837478, 39.728494, + 'Sacramento' => -121.494400, 38.581572, + 'Gridley' => -121.693583, 39.363777, + 'Marysville' => -121.591355, 39.145725, + 'Cupertino' => -122.032182, 37.322998 + ; + + protected $serializers = + Redis::SERIALIZER_NONE, + Redis::SERIALIZER_PHP, + ; + + protected function getNilValue() { + return FALSE; + } + + protected function getSerializers() { + $result = Redis::SERIALIZER_NONE, Redis::SERIALIZER_PHP; + + if (defined('Redis::SERIALIZER_IGBINARY')) + $result = Redis::SERIALIZER_IGBINARY; + if (defined('Redis::SERIALIZER_JSON')) + $result = Redis::SERIALIZER_JSON; + if (defined('Redis::SERIALIZER_MSGPACK')) + $result = Redis::SERIALIZER_MSGPACK; + + return $result; + } + + protected function getCompressors() { + $result'none' = Redis::COMPRESSION_NONE; + if (defined('Redis::COMPRESSION_LZF')) + $result'lzf' = Redis::COMPRESSION_LZF; + if (defined('Redis::COMPRESSION_LZ4')) + $result'lz4' = Redis::COMPRESSION_LZ4; + if (defined('Redis::COMPRESSION_ZSTD')) + $result'zstd' = Redis::COMPRESSION_ZSTD; + + return $result; + } + + /* Overridable left/right constants */ + protected function getLeftConstant() { + return Redis::LEFT; + } + + protected function getRightConstant() { + return Redis::RIGHT; + } + + protected function detectKeyDB(array $info) { + return strpos($info'executable' ?? '', 'keydb') !== false || + isset($info'keydb') || + isset($info'mvcc_depth'); + } + + protected function detectValkey(array $info) { + return isset($info'server_name') && $info'server_name' === 'valkey'; + } + + public function setUp() { + $this->redis = $this->newInstance(); + $info = $this->redis->info(); + $this->version = (isset($info'redis_version')?$info'redis_version':'0.0.0'); + $this->is_keydb = $this->detectKeyDB($info); + $this->is_valkey = $this->detectValKey($info); + $this->valkey_version = $info'valkey_version' ?? '0.0.0'; + } + + protected function haveCommand(string $cmd): bool { + $info = $this->redis->command('info', $cmd); + $name = $info00 ?? null; + + return $name && strcasecmp($cmd, $name) === 0; + } + + protected function minVersionCheck($version) { + return version_compare($this->version, $version) >= 0; + } + + protected function minValkeyVersionCheck($version) { + return $this->is_valkey && version_compare($this->valkey_version, $version) >= 0; + } + + protected function mstime() { + return round(microtime(true)*1000); + } + + protected function getAuthParts(&$user, &$pass) { + $user = $pass = NULL; + + $auth = $this->getAuth(); + if ( ! $auth) + return; + + if (is_array($auth)) { + if (count($auth) > 1) { + list($user, $pass) = $auth; + } else { + $pass = $auth0; + } + } else { + $pass = $auth; + } + } + + protected function sessionPrefix(): string { + return 'PHPREDIS_SESSION:'; + } + + protected function sessionSaveHandler(): string { + return 'redis'; + } + + protected function sessionSavePath(): string { + return sprintf('tcp://%s:%d?%s', $this->getHost(), $this->getPort(), + $this->getAuthFragment()); + } + + protected function getAuthFragment() { + $this->getAuthParts($user, $pass); + + if ($user && $pass) { + return sprintf('authuser=%s&authpass=%s', $user, $pass); + } else if ($pass) { + return sprintf('authpass=%s', $pass); + } else { + return ''; + } + } + + protected function newInstance() { + $r = new Redis( + 'host' => $this->getHost(), + 'port' => $this->getPort(), + ); + + if ($this->getAuth()) { + $this->assertTrue($r->auth($this->getAuth())); + } + return $r; + } + + public function tearDown() { + if ($this->redis) { + $this->redis->close(); + } + } + + public function reset() { + $this->setUp(); + $this->tearDown(); + } + + /* Helper function to determine if the class has pipeline support */ + protected function havePipeline() { + return defined(get_class($this->redis) . '::PIPELINE'); + } + + protected function haveMulti() { + return defined(get_class($this->redis) . '::MULTI'); + } + + public function testMinimumVersion() { + $this->assertTrue(version_compare($this->version, '2.4.0') >= 0); + } + + public function testPing() { + /* Reply literal off */ + $this->assertTrue($this->redis->ping()); + $this->assertTrue($this->redis->ping(NULL)); + $this->assertEquals('BEEP', $this->redis->ping('BEEP')); + + /* Make sure we're good in MULTI mode */ + if ($this->haveMulti()) { + $this->assertEquals( + true, 'BEEP', + $this->redis->multi() + ->ping() + ->ping('BEEP') + ->exec() + ); + } + } + + public function testPipelinePublish() {
View file
redis-6.3.0.tgz/redis-6.3.0/tests/SessionHelpers.php
Added
@@ -0,0 +1,358 @@ +<?php + +namespace SessionHelpers; + +class PhpSpawner { + protected static function appendPhpArgs(string $php): string { + $modules = shell_exec("$php --no-php-ini -m"); + + /* Determine if we need to specifically add extensions */ + $extensions = array_filter( + 'igbinary', 'msgpack', 'json', 'redis', + function ($module) use ($modules) { + return strpos($modules, $module) === false; + } + ); + + /* If any are needed add them to the command */ + if ($extensions) { + $php .= ' --no-php-ini'; + foreach ($extensions as $extension) { + /* We want to use the locally built redis extension */ + if ($extension == 'redis') { + $path = dirname(__DIR__) . '/modules/redis'; + if (is_file("{$path}.so")) + $extension = $path; + } + + $php .= " -dextension=$extension.so"; + } + } + + return $php; + } + + /** + * Return command to launch PHP with built extension enabled + * taking care of environment (TEST_PHP_EXECUTABLE and TEST_PHP_ARGS) + * + * @param string $script + * + * @return string + */ + public static function cmd(string $script): string { + static $cmd = NULL; + + if ( ! $cmd) { + $cmd = getenv('TEST_PHP_EXECUTABLE') ?: PHP_BINARY; + + if ($test_args = getenv('TEST_PHP_ARGS')) { + $cmd .= ' ' . $test_args; + } else { + $cmd = self::appendPhpArgs($cmd); + } + } + + return $cmd . ' ' . __DIR__ . '/' . $script . ' '; + } +} + +class Runner { + const start_script = 'startSession.php'; + const regenerate_id_script = 'regenerateSessionId.php'; + const get_data_script = 'getSessionData.php'; + + private $required = 'host', 'handler', 'id'; + + private $args = + 'handler' => null, + 'save-path' => null, + 'id' => null, + 'sleep' => 0, + 'max-execution-time' => 300, + 'locking-enabled' => true, + 'lock-wait-time' => null, + 'lock-retries' => -1, + 'lock-expires' => 0, + 'data' => '', + 'lifetime' => 1440, + 'compression' => 'none', + ; + + private $prefix = NULL; + private $output_file = NULL; + private $exit_code = -1; + private $cmd = NULL; + private $pid; + private $output; + + public function __construct() { + $this->args'id' = $this->createId(); + } + + public function __destruct() { + if ($this->output_file) { + unlink($this->output_file); + } + } + + public function getExitCode(): int { + return $this->exit_code; + } + + public function getCmd(): ?string { + return $this->cmd; + } + + public function getId(): ?string { + return $this->args'id'; + } + + public function prefix(string $prefix): self { + $this->prefix = $prefix; + return $this; + } + + public function getSessionKey(): string { + return $this->prefix . $this->getId(); + } + + public function getSessionLockKey(): string { + return $this->getSessionKey() . '_LOCK'; + } + + protected function set($setting, $v): self { + $this->args$setting = $v; + return $this; + } + + public function handler(string $handler): self { + return $this->set('handler', $handler); + } + + public function savePath(string $path): self { + return $this->set('save-path', $path); + } + + public function id(string $id): self { + return $this->set('id', $id); + } + + public function sleep(int $sleep): self { + return $this->set('sleep', $sleep); + } + + public function maxExecutionTime(int $time): self { + return $this->set('max-execution-time', $time); + } + + public function lockingEnabled(bool $enabled): self { + return $this->set('locking-enabled', $enabled); + } + + public function lockWaitTime(int $time): self { + return $this->set('lock-wait-time', $time); + } + + public function lockRetries(int $retries): self { + return $this->set('lock-retries', $retries); + } + + public function lockExpires(int $expires): self { + return $this->set('lock-expires', $expires); + } + + public function data(string $data): self { + return $this->set('data', $data); + } + + public function lifetime(int $lifetime): self { + return $this->set('lifetime', $lifetime); + } + + public function compression(string $compression): self { + return $this->set('compression', $compression); + } + + protected function validateArgs(array $required) { + foreach ($required as $req) { + if ( ! isset($this->args$req) || $this->args$req === null) + throw new \Exception("Command requires '$req' arg"); + } + } + + private function createId(): string { + if (function_exists('session_create_id')) + return session_create_id(); + + return uniqid(); + } + + private function getTmpFileName() { + return tempnam(sys_get_temp_dir(), 'session'); + } + + /* + * @param $client Redis client + * @param string $max_wait_sec + * + * Sometimes we want to block until a session lock has been detected
View file
redis-6.3.0.tgz/redis-6.3.0/tests/TestRedis.php
Changed
(renamed from redis-6.2.0/tests/TestRedis.php)
View file
redis-6.3.0.tgz/redis-6.3.0/tests/TestSuite.php
Added
@@ -0,0 +1,638 @@ +<?php defined('PHPREDIS_TESTRUN') or die("Use TestRedis.php to run tests!\n"); + +/* A specific exception for when we skip a test */ +class TestSkippedException extends Exception {} + +// phpunit is such a pain to install, we're going with pure-PHP here. +class TestSuite +{ + /* Host and port the unit tests will use */ + private string $host; + private ?int $port = 6379; + + /* Redis authentication we'll use */ + private $auth; + + /* Redis server version */ + protected $version; + protected string $valkey_version; + protected bool $is_keydb; + protected bool $is_valkey; + + private static bool $colorize = false; + + private static $BOLD_ON = "\0331m"; + private static $BOLD_OFF = "\0330m"; + + private static $BLACK = "\0330;30m"; + private static $DARKGRAY = "\0331;30m"; + private static $BLUE = "\0330;34m"; + private static $PURPLE = "\0330;35m"; + private static $GREEN = "\0330;32m"; + private static $YELLOW = "\0330;33m"; + private static $RED = "\0330;31m"; + + public static array $errors = ; + public static array $warnings = ; + + public function __construct(string $host, ?int $port, $auth) { + $this->host = $host; + $this->port = $port; + $this->auth = $auth; + } + + public function getHost() { return $this->host; } + public function getPort() { return $this->port; } + public function getAuth() { return $this->auth; } + + public static function errorMessage(string $fmt, ...$args) { + $msg = vsprintf($fmt . "\n", $args); + + if (defined('STDERR')) { + fwrite(STDERR, $msg); + } else { + echo $msg; + } + } + + public static function make_bold(string $msg) { + return self::$colorize ? self::$BOLD_ON . $msg . self::$BOLD_OFF : $msg; + } + + public static function make_success(string $msg) { + return self::$colorize ? self::$GREEN . $msg . self::$BOLD_OFF : $msg; + } + + public static function make_fail(string $msg) { + return self::$colorize ? self::$RED . $msg . self::$BOLD_OFF : $msg; + } + + public static function make_warning(string $msg) { + return self::$colorize ? self::$YELLOW . $msg . self::$BOLD_OFF : $msg; + } + + protected function printArg($v) { + if (is_null($v)) + return '(null)'; + else if ($v === false || $v === true) + return $v ? '(true)' : '(false)'; + else if (is_string($v)) + return "'$v'"; + else + return print_r($v, true); + } + + protected function findTestFunction($bt) { + $i = 0; + while (isset($bt$i)) { + if (substr($bt$i'function', 0, 4) == 'test') + return $bt$i'function'; + $i++; + } + return NULL; + } + + protected function assertionTrace(?string $fmt = NULL, ...$args) { + $prefix = 'Assertion failed:'; + + $lines = ; + + $bt = debug_backtrace(); + + $msg = $fmt ? vsprintf($fmt, $args) : NULL; + + $fn = $this->findTestFunction($bt); + $lines = sprintf("%s %s - %s", $prefix, self::make_bold($fn), + $msg ? $msg : '(no message)'); + + array_shift($bt); + + for ($i = 0; $i < count($bt); $i++) { + $file = $bt$i'file'; + $line = $bt$i'line'; + $fn = $bt$i+1'function' ?? $bt$i'function'; + + $lines = sprintf("%s %s:%d (%s)%s", + str_repeat(' ', strlen($prefix)), $file, $line, + $fn, $msg ? " $msg" : ''); + + if (substr($fn, 0, 4) == 'test') + break; + } + + return implode("\n", $lines) . "\n"; + } + + protected function assert($fmt, ...$args) { + self::$errors = $this->assertionTrace($fmt, ...$args); + } + + protected function assertKeyEquals($expected, $key, $redis = NULL): bool { + $actual = ($redis ??= $this->redis)->get($key); + if ($actual === $expected) + return true; + + self::$errors = $this->assertionTrace("%s !== %s", $this->printArg($actual), + $this->printArg($expected)); + + return false; + } + + protected function assertKeyEqualsWeak($expected, $key, $redis = NULL): bool { + $actual = ($redis ??= $this->redis)->get($key); + if ($actual == $expected) + return true; + + self::$errors = $this->assertionTrace("%s != %s", $this->printArg($actual), + $this->printArg($expected)); + + return false; + } + + protected function assertKeyExists($key, $redis = NULL): bool { + if (($redis ??= $this->redis)->exists($key)) + return true; + + self::$errors = $this->assertionTrace("Key '%s' does not exist.", $key); + + return false; + } + + protected function assertKeyMissing($key, $redis = NULL): bool { + if ( ! ($redis ??= $this->redis)->exists($key)) + return true; + + self::$errors = $this->assertionTrace("Key '%s' exists but shouldn't.", $key); + + return false; + } + + protected function assertTrue($value): bool { + if ($value === true) + return true; + + self::$errors = $this->assertionTrace("%s !== %s", $this->printArg($value), + $this->printArg(true)); + + return false; + } + + protected function assertFalse($value): bool { + if ($value === false) + return true; + + self::$errors = $this->assertionTrace("%s !== %s", $this->printArg($value), + $this->printArg(false)); + + return false; + } + + protected function assertNull($value): bool { + if ($value === NULL) + return true; + + self::$errors = $this->assertionTrace("%s !== %s", $this->printArg($value), + $this->printArg(NULL)); + + return false; + } +
View file
redis-6.3.0.tgz/redis-6.3.0/tests/getSessionData.php
Changed
(renamed from redis-6.2.0/tests/getSessionData.php)
View file
redis-6.3.0.tgz/redis-6.3.0/tests/make-cluster.sh
Changed
(renamed from redis-6.2.0/tests/make-cluster.sh)
View file
redis-6.3.0.tgz/redis-6.3.0/tests/mkring.sh
Changed
(renamed from redis-6.2.0/tests/mkring.sh)
View file
redis-6.3.0.tgz/redis-6.3.0/tests/regenerateSessionId.php
Changed
(renamed from redis-6.2.0/tests/regenerateSessionId.php)
View file
redis-6.3.0.tgz/redis-6.3.0/tests/startSession.php
Changed
(renamed from redis-6.2.0/tests/startSession.php)
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.