More work on pecl-memcache (#76)

* Use zend_bool for ini bool settings

Related to #56

* Initial work for php 8

* php7 -> php8

* Add test for #53

* Fix support for binary protocol

* php8 -> src

* Backwards compatibility with php 7.3, 7.4

This will allow us to have one unified branch that will compile
under different versions of php.

* Add test for pecl bug #77900

* Fix some memory leaks

* Support for reflection

- added / updated arginfos
- fix functions returning NULL instead of advertised return type,
  For example, when memcached returned error on "delete", function
  returned null instead of false
- added tests for both php8 and 7

* Fix typo

* Update config.w32

Co-authored-by: Tyson Andre <tyson.andre@uwaterloo.ca>

Co-authored-by: Tyson Andre <tysonandre775@hotmail.com>
Co-authored-by: Tomas Srnka <tomassrnka@users.noreply.github.com>
Co-authored-by: Tyson Andre <tyson.andre@uwaterloo.ca>
This commit is contained in:
Zaffy
2020-10-16 09:52:01 +02:00
committed by GitHub
parent 7889bd1d23
commit e090f05a05
34 changed files with 2319 additions and 164 deletions

View File

@@ -9,8 +9,8 @@ if (PHP_MEMCACHE != "no") {
var dll = get_define('PHPDLL');
var old_conf_dir = configure_module_dirname;
if (dll.match(/^php8/) != null) {
configure_module_dirname = configure_module_dirname + "\\php8";
if (dll.match(/^php[78]/) != null) {
configure_module_dirname = configure_module_dirname + "\\src";
} else if (dll.match(/^php5/) != null) {
ERROR("PHP 7.x required for pecl-php-memcache ver 4+. Use pecl-php-meachce ver 3.x for PHP 5.x.");
} else {

View File

@@ -64,7 +64,7 @@ if test "$PHP_MEMCACHE" != "no"; then
fi
AC_MSG_CHECKING(PHP version)
if test -d $abs_srcdir/php8 ; then
if test -d $abs_srcdir/src ; then
dnl # only when for PECL, not for PHP
export OLD_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS $INCLUDES"
@@ -73,7 +73,7 @@ if test "$PHP_MEMCACHE" != "no"; then
#error "PHP < 7"
#endif
], [
subdir=php8
subdir=src
AC_MSG_RESULT([PHP 7.x])
],
AC_MSG_ERROR([PHP 7.x required for pecl-php-memcache ver 4+. Use pecl-php-memcache ver 3.x for PHP 5.x.])

View File

@@ -29,4 +29,8 @@ chown memcache:memcache /var/run/memcached
# Let's start tests
cd /usr/src/pecl-memcache
NO_INTERACTION=1 TEST_PHP_ARGS="--show-diff --keep-all -w fails.log" make test
export NO_INTERACTION=1
export TEST_PHP_ARGS="--show-diff --keep-all -w fails.log"
MEMCACHE_PROTOCOL=ascii make test
MEMCACHE_PROTOCOL=binary make test

View File

@@ -66,7 +66,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
<file name="host.conf" role="src" />
<file name="start.sh" role="src" />
</dir>
<dir name="php8">
<dir name="src">
<file name="memcache.c" role="src" />
<file name="memcache_pool.c" role="src" />
<file name="memcache_queue.c" role="src" />

View File

@@ -26,6 +26,7 @@
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "ext/standard/php_string.h"
#include "php_memcache.h"
/* True global resources - no need for thread safety here */
@@ -38,123 +39,145 @@ ZEND_EXTERN_MODULE_GLOBALS(memcache)
/* {{{ memcache_functions[]
*/
#ifndef ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX
#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(name, ref, num, type) \
ZEND_BEGIN_ARG_INFO_EX(name, 0u, ref, num)
#endif
#ifndef ZEND_ARG_TYPE_MASK
#define ZEND_ARG_TYPE_MASK(ref, name, mask, def) \
ZEND_ARG_INFO(ref, name)
#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_connect, 0, 0, 1)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, port)
ZEND_ARG_INFO(0, udp_port)
ZEND_ARG_INFO(0, persistent)
ZEND_ARG_INFO(0, weight)
ZEND_ARG_INFO(0, timeout)
ZEND_ARG_INFO(0, retry_interval)
ZEND_ARG_INFO(0, unused4)
ZEND_ARG_INFO(0, unused5)
ZEND_ARG_INFO(0, unused6)
ZEND_ARG_INFO(0, unused7)
ZEND_ARG_INFO(0, unugsed8)
ZEND_END_ARG_INFO()
#define arginfo_memcache_pconnect arginfo_memcache_connect
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_add_server, 0, 0, 2)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_add_server, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, port)
ZEND_ARG_INFO(0, tcp_port)
ZEND_ARG_INFO(0, persistent)
ZEND_ARG_INFO(0, weight)
ZEND_ARG_INFO(0, timeout)
ZEND_ARG_INFO(0, retry_interval)
ZEND_ARG_INFO(0, status)
ZEND_ARG_INFO(0, failure_callback)
ZEND_ARG_INFO(0, timeoutms)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_set_server_params, 0, 0, 1)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, port)
ZEND_ARG_INFO(0, timeout)
ZEND_ARG_INFO(0, retry_interval)
ZEND_ARG_INFO(0, status)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_set_server_params, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, tcp_port, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0)
ZEND_ARG_TYPE_INFO(0, retry_interval, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, status, _IS_BOOL, 0)
ZEND_ARG_INFO(0, failure_callback)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_set_failure_callback, 1, 0, 2)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_set_failure_callback, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_ARG_INFO(0, failure_callback)
ZEND_ARG_TYPE_INFO(0, failure_callback, IS_CALLABLE, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_get_server_status, 0, 0, 1)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, port)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_get_server_status, 0, 2, MAY_BE_BOOL|MAY_BE_LONG)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, tcp_port, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_get_version, 1, 0, 1)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_get_version, 0, 1, MAY_BE_STRING|MAY_BE_BOOL)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_add, 0, 0, 2)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_add, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_ARG_INFO(0, key)
ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, 0)
#ifdef IS_MIXED
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
#else
ZEND_ARG_INFO(0, value)
ZEND_ARG_INFO(0, flag)
ZEND_ARG_INFO(0, exptime)
#endif
ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, exptime, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, cas, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_memcache_set arginfo_memcache_add
#define arginfo_memcache_replace arginfo_memcache_add
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_cas, 0, 0, 2)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, value)
ZEND_ARG_INFO(0, flag)
ZEND_ARG_INFO(0, exptime)
ZEND_ARG_INFO(0, cas)
ZEND_END_ARG_INFO()
#define arginfo_memcache_cas arginfo_memcache_add
#define arginfo_memcache_append arginfo_memcache_add
#define arginfo_memcache_prepend arginfo_memcache_add
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_get, 1, 0, 2)
#ifdef IS_MIXED
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_get, 0, 2, IS_MIXED, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_get, 0, 0, 1)
#endif
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(1, flags)
ZEND_ARG_INFO(1, cas)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_delete, 0, 0, 2)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_delete, 0, 2, MAY_BE_BOOL|MAY_BE_ARRAY)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, exptime)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_debug, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_debug, 0, 1, _IS_BOOL, 0)
ZEND_ARG_INFO(0, on_off)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_get_stats, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_get_stats, 0, 1, MAY_BE_BOOL|MAY_BE_ARRAY)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_ARG_INFO(0, type)
ZEND_ARG_INFO(0, slabid)
ZEND_ARG_INFO(0, limit)
ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, slabid, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, limit, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_memcache_get_extended_stats arginfo_memcache_get_stats
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_set_compress_threshold, 0, 0, 2)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_set_compress_threshold, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_ARG_INFO(0, threshold)
ZEND_ARG_INFO(0, min_savings)
ZEND_ARG_TYPE_INFO(0, threshold, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, min_savings, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_increment, 0, 0, 2)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_increment, 0, 2, MAY_BE_BOOL|MAY_BE_ARRAY|MAY_BE_LONG)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, value)
ZEND_ARG_INFO(0, defval)
ZEND_ARG_INFO(0, exptime)
ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, value, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, defval, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, exptime, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_memcache_decrement arginfo_memcache_increment
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_close, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_close, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_flush, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_flush, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_ARG_INFO(0, delay)
ZEND_ARG_TYPE_INFO(0, delay, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_set_sasl_auth_data, 1, 0, 3)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_set_sasl_auth_data, 0, 3, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, memcache, MemcachePool, 0)
ZEND_ARG_INFO(0, username)
ZEND_ARG_INFO(0, password)
ZEND_ARG_TYPE_INFO(0, username, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, password, IS_STRING, 0)
ZEND_END_ARG_INFO()
zend_function_entry memcache_functions[] = {
@@ -185,99 +208,142 @@ zend_function_entry memcache_functions[] = {
ZEND_FE_END
};
#define arginfo_memcache_object_connect arginfo_memcache_connect
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_addserver, 0, 0, 1)
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_pool_object_connect, 0, 0, 1)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, port)
ZEND_ARG_INFO(0, tcp_port)
ZEND_ARG_INFO(0, udp_port)
ZEND_ARG_INFO(0, persistent)
ZEND_ARG_INFO(0, weight)
ZEND_ARG_INFO(0, timeout)
ZEND_ARG_INFO(0, retry_interval)
ZEND_END_ARG_INFO()
#define arginfo_memcache_object_connect arginfo_memcache_connect
#define arginfo_memcache_object_pconnect arginfo_memcache_connect
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_pool_object_addserver, 0, 1, _IS_BOOL, 0)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, tcp_port)
ZEND_ARG_INFO(0, udp_port)
ZEND_ARG_INFO(0, persistent)
ZEND_ARG_INFO(0, weight)
ZEND_ARG_INFO(0, timeout)
ZEND_ARG_INFO(0, retry_interval)
ZEND_ARG_INFO(0, status)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_addserver, 0, 1, _IS_BOOL, 0)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, tcp_port)
ZEND_ARG_INFO(0, persistent)
ZEND_ARG_INFO(0, weight)
ZEND_ARG_INFO(0, timeout)
ZEND_ARG_INFO(0, retry_interval)
ZEND_ARG_INFO(0, status)
ZEND_ARG_INFO(0, failure_callback)
ZEND_ARG_INFO(0, timeoutms)
ZEND_END_ARG_INFO()
#define arginfo_memcache_object_setserverparams arginfo_memcache_set_server_params
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_setfailurecallback, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_setserverparams, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, tcp_port, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0)
ZEND_ARG_TYPE_INFO(0, retry_interval, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, status, _IS_BOOL, 0)
ZEND_ARG_INFO(0, failure_callback)
ZEND_END_ARG_INFO()
#define arginfo_memcache_object_getserverstatus arginfo_memcache_get_server_status
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_setfailurecallback, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, failure_callback, IS_CALLABLE, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_findserver, 0, 0, 1)
ZEND_ARG_INFO(0, key)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_object_getserverstatus, 0, 1, MAY_BE_BOOL|MAY_BE_LONG)
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, tcp_port, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_getversion, 0, 0, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_object_findserver, 0, 1, MAY_BE_STRING|MAY_BE_BOOL)
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_add, 0, 0, 1)
ZEND_ARG_INFO(0, key)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_object_getversion, 0, 0, MAY_BE_STRING|MAY_BE_BOOL)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_add, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, 0)
#ifdef IS_MIXED
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
#else
ZEND_ARG_INFO(0, value)
ZEND_ARG_INFO(0, flag)
ZEND_ARG_INFO(0, exptime)
#endif
ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, exptime, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, cas, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_memcache_object_set arginfo_memcache_object_add
#define arginfo_memcache_object_replace arginfo_memcache_object_add
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_cas, 0, 0, 1)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, value)
ZEND_ARG_INFO(0, flag)
ZEND_ARG_INFO(0, exptime)
ZEND_ARG_INFO(0, cas)
ZEND_END_ARG_INFO()
#define arginfo_memcache_object_set arginfo_memcache_object_add
#define arginfo_memcache_object_cas arginfo_memcache_object_add
#define arginfo_memcache_object_append arginfo_memcache_object_add
#define arginfo_memcache_object_prepend arginfo_memcache_object_add
#ifdef IS_MIXED
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_get, 0, 1, IS_MIXED, 0)
#else
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_get, 0, 0, 1)
ZEND_ARG_INFO(0, key)
#endif
ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, 0)
#ifdef IS_MIXED
ZEND_ARG_TYPE_INFO(1, flags, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO(1, cas, IS_MIXED, 0)
#else
ZEND_ARG_INFO(1, flags)
ZEND_ARG_INFO(1, cas)
#endif
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_delete, 0, 0, 1)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, exptime)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_object_delete, 0, 1, MAY_BE_BOOL|MAY_BE_ARRAY)
ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, exptime, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_getstats, 0, 0, 0)
ZEND_ARG_INFO(0, type)
ZEND_ARG_INFO(0, slabid)
ZEND_ARG_INFO(0, limit)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_object_getstats, 0, 0, MAY_BE_BOOL|MAY_BE_ARRAY)
ZEND_ARG_TYPE_INFO(0, type, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, slabid, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, limit, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_memcache_object_getextendedstats arginfo_memcache_object_getstats
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_setcompressthreshold, 0, 0, 1)
ZEND_ARG_INFO(0, threshold)
ZEND_ARG_INFO(0, min_savings)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_setcompressthreshold, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, threshold, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, min_savings, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_increment, 0, 0, 1)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, value)
ZEND_ARG_INFO(0, defval)
ZEND_ARG_INFO(0, exptime)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_memcache_object_increment, 0, 1, MAY_BE_BOOL|MAY_BE_ARRAY|MAY_BE_LONG)
ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, value, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, defval, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, exptime, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_memcache_object_decrement arginfo_memcache_object_increment
ZEND_BEGIN_ARG_INFO(arginfo_memcache_object_close, 0)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_close, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_flush, 0, 0, 0)
ZEND_ARG_INFO(0, delay)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_flush, 0, 0, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, delay, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_memcache_object_setSaslAuthData, 0, 0, 2)
ZEND_ARG_INFO(0, username)
ZEND_ARG_INFO(0, password)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memcache_object_setSaslAuthData, 0, 2, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, username, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, password, IS_STRING, 0)
ZEND_END_ARG_INFO()
static zend_function_entry php_memcache_pool_class_functions[] = {
PHP_NAMED_FE(connect, zif_memcache_pool_connect, arginfo_memcache_object_connect)
PHP_NAMED_FE(addserver, zif_memcache_pool_addserver, arginfo_memcache_object_addserver)
PHP_NAMED_FE(connect, zif_memcache_pool_connect, arginfo_memcache_pool_object_connect)
PHP_NAMED_FE(addserver, zif_memcache_pool_addserver, arginfo_memcache_pool_object_addserver)
PHP_FALIAS(setserverparams, memcache_set_server_params, arginfo_memcache_object_setserverparams)
PHP_FALIAS(setfailurecallback, memcache_set_failure_callback, arginfo_memcache_object_setfailurecallback)
PHP_FALIAS(getserverstatus, memcache_get_server_status, arginfo_memcache_object_getserverstatus)
@@ -303,8 +369,8 @@ static zend_function_entry php_memcache_pool_class_functions[] = {
};
static zend_function_entry php_memcache_class_functions[] = {
PHP_ME_MAPPING(connect, memcache_connect, arginfo_memcache_connect, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(pconnect, memcache_pconnect, arginfo_memcache_pconnect, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(connect, memcache_connect, arginfo_memcache_object_connect, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(pconnect, memcache_pconnect, arginfo_memcache_object_pconnect, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(addserver, memcache_add_server, arginfo_memcache_object_addserver, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
@@ -487,14 +553,14 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("memcache.session_redundancy", "2", PHP_INI_ALL, OnUpdateRedundancy, session_redundancy, zend_memcache_globals, memcache_globals)
STD_PHP_INI_ENTRY("memcache.compress_threshold", "20000", PHP_INI_ALL, OnUpdateCompressThreshold, compress_threshold, zend_memcache_globals, memcache_globals)
STD_PHP_INI_ENTRY("memcache.lock_timeout", "15", PHP_INI_ALL, OnUpdateLockTimeout, lock_timeout, zend_memcache_globals, memcache_globals)
STD_PHP_INI_ENTRY("memcache.session_prefix_host_key", "0", PHP_INI_ALL, OnUpdateBool, session_prefix_host_key, zend_memcache_globals, memcache_globals)
STD_PHP_INI_ENTRY("memcache.session_prefix_host_key_remove_www", "1", PHP_INI_ALL, OnUpdateBool, session_prefix_host_key_remove_www, zend_memcache_globals, memcache_globals)
STD_PHP_INI_ENTRY("memcache.session_prefix_host_key_remove_subdomain", "0", PHP_INI_ALL, OnUpdateBool, session_prefix_host_key_remove_subdomain, zend_memcache_globals, memcache_globals)
STD_PHP_INI_BOOLEAN("memcache.session_prefix_host_key", "0", PHP_INI_ALL, OnUpdateBool, session_prefix_host_key, zend_memcache_globals, memcache_globals)
STD_PHP_INI_BOOLEAN("memcache.session_prefix_host_key_remove_www", "1", PHP_INI_ALL, OnUpdateBool, session_prefix_host_key_remove_www, zend_memcache_globals, memcache_globals)
STD_PHP_INI_BOOLEAN("memcache.session_prefix_host_key_remove_subdomain", "0", PHP_INI_ALL, OnUpdateBool, session_prefix_host_key_remove_subdomain, zend_memcache_globals, memcache_globals)
STD_PHP_INI_ENTRY("memcache.session_prefix_static_key", NULL, PHP_INI_ALL, OnUpdatePrefixStaticKey, session_prefix_static_key, zend_memcache_globals, memcache_globals)
STD_PHP_INI_ENTRY("memcache.session_save_path", NULL, PHP_INI_ALL, OnUpdateString, session_save_path, zend_memcache_globals, memcache_globals)
STD_PHP_INI_ENTRY("memcache.prefix_host_key", "0", PHP_INI_ALL, OnUpdateBool, prefix_host_key, zend_memcache_globals, memcache_globals)
STD_PHP_INI_ENTRY("memcache.prefix_host_key_remove_www", "1", PHP_INI_ALL, OnUpdateBool, prefix_host_key_remove_www, zend_memcache_globals, memcache_globals)
STD_PHP_INI_ENTRY("memcache.prefix_host_key_remove_subdomain", "0", PHP_INI_ALL, OnUpdateBool, prefix_host_key_remove_subdomain, zend_memcache_globals, memcache_globals)
STD_PHP_INI_BOOLEAN("memcache.prefix_host_key", "0", PHP_INI_ALL, OnUpdateBool, prefix_host_key, zend_memcache_globals, memcache_globals)
STD_PHP_INI_BOOLEAN("memcache.prefix_host_key_remove_www", "1", PHP_INI_ALL, OnUpdateBool, prefix_host_key_remove_www, zend_memcache_globals, memcache_globals)
STD_PHP_INI_BOOLEAN("memcache.prefix_host_key_remove_subdomain", "0", PHP_INI_ALL, OnUpdateBool, prefix_host_key_remove_subdomain, zend_memcache_globals, memcache_globals)
STD_PHP_INI_ENTRY("memcache.prefix_static_key", NULL, PHP_INI_ALL, OnUpdatePrefixStaticKey, prefix_static_key, zend_memcache_globals, memcache_globals)
PHP_INI_END()
/* }}} */
@@ -1062,6 +1128,10 @@ static void php_mmc_numeric(INTERNAL_FUNCTION_PARAMETERS, int deleted, int inver
/* execute all requests */
mmc_pool_run(pool);
if (Z_TYPE_P(return_value) == IS_NULL) {
RETURN_FALSE;
}
}
/* }}} */
@@ -1073,7 +1143,7 @@ static void php_mmc_numeric(INTERNAL_FUNCTION_PARAMETERS, int deleted, int inver
memcpy((char *)persistent_id, key, key_len+1);
if (zend_register_persistent_resource ( (char*) persistent_id, key_len, mmc, le_memcache_server) == NULL) ;
then not forget to pefree, check refcounts in _mmc_server_free / _mmc_server_list_dtor , etc.
then not forget to pefree, check refcounts in _mmc_server_free / _mmc_server_list_dtor , etc.
otherwise we will leak mem with persistent connections /run into other trouble with later versions
*/
mmc_t *mmc_find_persistent(const char *host, int host_len, unsigned short port, unsigned short udp_port, double timeout, int retry_interval) /* {{{ */
@@ -1213,8 +1283,13 @@ static mmc_t *php_mmc_pool_addserver(
if (pool->protocol == &mmc_binary_protocol) {
zval rv1, rv2;
#if PHP_VERSION_ID >= 80000
zval *username = zend_read_property(memcache_ce, Z_OBJ_P(mmc_object), "username", strlen("username"), 1, &rv1);
zval *password = zend_read_property(memcache_ce, Z_OBJ_P(mmc_object), "password", strlen("password"), 1, &rv2);
#else
zval *username = zend_read_property(memcache_ce, mmc_object, "username", strlen("username"), 1, &rv1);
zval *password = zend_read_property(memcache_ce, mmc_object, "password", strlen("password"), 1, &rv2);
#endif
if (Z_TYPE_P(username) == IS_STRING && Z_TYPE_P(password) == IS_STRING) {
if (Z_STRLEN_P(username) > 1 && Z_STRLEN_P(password) > 1) {
mmc_request_t *request;
@@ -1887,6 +1962,10 @@ PHP_FUNCTION(memcache_get_version)
}
}
}
if (Z_TYPE_P(return_value) == IS_NULL) {
RETURN_FALSE;
}
}
/* }}} */
@@ -2079,19 +2158,23 @@ PHP_FUNCTION(memcache_get)
if (mmc_prepare_key(keys, request->key, &(request->key_len)) != MMC_OK) {
mmc_pool_release(pool, request);
php_error_docref(NULL, E_WARNING, "Invalid key");
return;
RETURN_FALSE;
}
pool->protocol->get(request, cas != NULL ? MMC_OP_GETS : MMC_OP_GET, keys, request->key, request->key_len);
/* schedule request */
if (mmc_pool_schedule_key(pool, request->key, request->key_len, request, 1) != MMC_OK) {
return;
RETURN_FALSE;
}
}
/* execute all requests */
mmc_pool_run(pool);
if (Z_TYPE_P(return_value) == IS_NULL) {
RETURN_FALSE;
}
}
/* }}} */
@@ -2198,6 +2281,10 @@ PHP_FUNCTION(memcache_get_stats)
/* execute all requests */
mmc_pool_run(pool);
if (Z_TYPE_P(return_value) == IS_NULL) {
RETURN_FALSE;
}
}
/* }}} */
@@ -2255,6 +2342,10 @@ PHP_FUNCTION(memcache_get_extended_stats)
/* execute all requests */
mmc_pool_run(pool);
if (Z_TYPE_P(return_value) == IS_NULL) {
RETURN_FALSE;
}
}
/* }}} */
@@ -2439,8 +2530,13 @@ PHP_FUNCTION(memcache_set_sasl_auth_data)
if (user_length < 1 || password_length < 1) {
RETURN_FALSE;
}
#if PHP_VERSION_ID >= 80000
zend_update_property_stringl(memcache_pool_ce, Z_OBJ_P(mmc_object), "username", strlen("username"), user, user_length);
zend_update_property_stringl(memcache_pool_ce, Z_OBJ_P(mmc_object), "password", strlen("password"), password, password_length);
#else
zend_update_property_stringl(memcache_pool_ce, mmc_object, "username", strlen("username"), user, user_length);
zend_update_property_stringl(memcache_pool_ce, mmc_object, "password", strlen("password"), password, password_length);
#endif
RETURN_TRUE;
}
/* }}} */
@@ -2450,6 +2546,8 @@ PHP_FUNCTION(memcache_set_sasl_auth_data)
PHP_FUNCTION(memcache_debug)
{
php_error_docref(NULL, E_WARNING, "memcache_debug() is deprecated, please use a debugger (like Eclipse + CDT)");
RETVAL_BOOL(PHP_DEBUG);
}
/* }}} */

View File

@@ -56,11 +56,16 @@ static int mmc_stream_get_line(mmc_stream_t *io, char **line) /*
}
/* }}} */
static int mmc_request_check_response(const char *line, int line_len) /*
static int mmc_request_check_response(char *line, int line_len) /*
checks for response status and error codes {{{ */
{
int response;
// remove newline and thus prevent passing it to userland
if (line_len >= 2 && line[line_len - 2] == '\r' && line[line_len - 1] == '\n') {
line[line_len - 2] = '\0';
}
if (mmc_str_left(line, "OK", line_len, sizeof("OK")-1) ||
mmc_str_left(line, "STORED", line_len, sizeof("STORED")-1) ||
mmc_str_left(line, "DELETED", line_len, sizeof("DELETED")-1))

View File

@@ -61,6 +61,12 @@ uint64_t mmc_htonll(uint64_t value);
# define htonll mmc_htonll
#endif
#ifdef __GNUC__
# define MMC_ATTR_PACKED __attribute__((packed))
#else
# define MMC_ATTR_PACKED
#endif /* UD_ATTR_PACKED */
#define MMC_REQUEST_MAGIC 0x80
#define MMC_RESPONSE_MAGIC 0x81
@@ -79,6 +85,15 @@ uint64_t mmc_htonll(uint64_t value);
#define MMC_BIN_OP_APPEND 0x0e
#define MMC_BIN_OP_PREPEND 0x0f
#define MMC_BINARY_STATUS_OK 0x00
#define MMC_BINARY_STATUS_KEY_NOT_FOUND 0x01
#define MMC_BINARY_STATUS_KEY_EXISTS 0x02
#define MMC_BINARY_STATUS_VALUE_TOO_LARGE 0x03
#define MMC_BINARY_STATUS_INVALID_ARGS 0x04
#define MMC_BINARY_STATUS_ITEM_NOT_STORED 0x05
#define MMC_BINARY_STATUS_INCR_DECR_ERROR 0x06 /* Incr/Decr on non-numeric value */
#define MMC_BINARY_STATUS_UNKNOWN_COMMAND 0x81
#define MMC_BINARY_STATUS_OUT_OF_MEMORY 0x82
#define MMC_OP_SASL_LIST 0x20
#define MMC_OP_SASL_AUTH 0x21
@@ -90,7 +105,7 @@ typedef struct mmc_binary_request {
mmc_queue_t keys; /* mmc_queue_t<zval *>, reqid -> key mappings */
struct {
uint8_t opcode;
uint8_t error; /* error received in current request */
uint16_t error; /* error received in current request */
uint32_t reqid; /* current reqid being processed */
} command;
struct { /* stores value info while the body is being read */
@@ -107,64 +122,63 @@ typedef struct mmc_request_header {
uint8_t extras_len;
uint8_t datatype;
uint16_t _reserved;
uint32_t length; /* trailing body length (not including this header) */
uint32_t length; /* trailing body total_body_length (not including this header) */
uint32_t reqid; /* opaque request id */
uint64_t cas;
} mmc_request_header_t;
} MMC_ATTR_PACKED mmc_request_header_t;
typedef struct mmc_get_request_header {
mmc_request_header_t base;
} mmc_get_request_header_t;
} MMC_ATTR_PACKED mmc_get_request_header_t;
typedef struct mmc_version_request_header {
mmc_request_header_t base;
} mmc_version_request_header_t;
} MMC_ATTR_PACKED mmc_version_request_header_t;
typedef struct mmc_store_request_header {
mmc_request_header_t base;
uint32_t flags;
uint32_t exptime;
} mmc_store_request_header_t;
} MMC_ATTR_PACKED mmc_store_request_header_t;
typedef struct mmc_store_append_header {
mmc_request_header_t base;
} mmc_store_append_header_t;
} MMC_ATTR_PACKED mmc_store_append_header_t;
typedef struct mmc_delete_request_header {
mmc_request_header_t base;
uint32_t exptime;
} mmc_delete_request_header_t;
} MMC_ATTR_PACKED mmc_delete_request_header_t;
typedef struct mmc_mutate_request_header {
mmc_request_header_t base;
uint64_t delta;
uint64_t initial;
uint32_t expiration;
} mmc_mutate_request_header_t;
} MMC_ATTR_PACKED mmc_mutate_request_header_t;
typedef struct mmc_sasl_request_header {
mmc_request_header_t base;
} mmc_sasl_request_header;
} MMC_ATTR_PACKED mmc_sasl_request_header;
typedef struct mmc_response_header {
uint8_t magic;
uint8_t opcode;
uint16_t error;
uint16_t key_len;
uint8_t extras_len;
uint8_t datatype;
uint16_t status;
uint32_t length; /* trailing body length (not including this header) */
uint32_t total_body_length; /* trailing body total_body_length (not including this header) */
uint32_t reqid; /* echo'ed from request */
uint64_t cas;
} mmc_response_header_t;
} MMC_ATTR_PACKED mmc_response_header_t;
typedef struct mmc_get_response_header {
uint32_t flags;
} mmc_get_response_header_t;
} MMC_ATTR_PACKED mmc_get_response_header_t;
typedef struct mmc_mutate_response_header {
uint64_t value;
} mmc_mutate_response_header_t;
} MMC_ATTR_PACKED mmc_mutate_response_header_t;
static int mmc_request_read_response(mmc_t *, mmc_request_t *);
static int mmc_request_parse_value(mmc_t *, mmc_request_t *);
@@ -252,9 +266,40 @@ static int mmc_request_parse_response(mmc_t *mmc, mmc_request_t *request) /*
}
req->command.opcode = header->opcode;
req->command.error = ntohs(header->error);
switch (ntohs(header->status)) {
case MMC_BINARY_STATUS_OK:
req->command.error = MMC_OK;
break;
case MMC_BINARY_STATUS_KEY_NOT_FOUND:
req->command.error = MMC_RESPONSE_NOT_FOUND;
break;
case MMC_BINARY_STATUS_KEY_EXISTS:
req->command.error = MMC_RESPONSE_EXISTS;
break;
case MMC_BINARY_STATUS_VALUE_TOO_LARGE:
req->command.error = MMC_RESPONSE_TOO_LARGE;
break;
case MMC_BINARY_STATUS_INVALID_ARGS:
case MMC_BINARY_STATUS_INCR_DECR_ERROR:
req->command.error = MMC_RESPONSE_CLIENT_ERROR;
break;
case MMC_BINARY_STATUS_ITEM_NOT_STORED:
req->command.error = MMC_RESPONSE_NOT_STORED;
break;
case MMC_BINARY_STATUS_UNKNOWN_COMMAND:
req->command.error = MMC_RESPONSE_UNKNOWN_CMD;
break;
case MMC_BINARY_STATUS_OUT_OF_MEMORY:
req->command.error = MMC_RESPONSE_OUT_OF_MEMORY;
break;
default:
req->command.error = MMC_RESPONSE_UNKNOWN;
break;
}
req->command.reqid = ntohl(header->reqid);
req->value.length = ntohl(header->length);
req->value.length = ntohl(header->total_body_length);
req->value.cas = ntohll(header->cas);
if (req->value.length == 0) {
@@ -434,6 +479,7 @@ static inline void mmc_pack_header(mmc_request_header_t *header, uint8_t opcode,
header->_reserved = 0;
header->length = htonl(key_len + extras_len + length);
header->reqid = htonl(reqid);
header->cas = 0;
}
/* }}} */
@@ -618,8 +664,7 @@ static void mmc_binary_delete(mmc_request_t *request, const char *key, unsigned
request->parse = mmc_request_parse_response;
req->next_parse_handler = mmc_request_read_response;
mmc_pack_header(&(header.base), MMC_OP_DELETE, 0, key_len, sizeof(header) - sizeof(header.base), 0);
header.exptime = htonl(exptime);
mmc_pack_header(&(header.base), MMC_OP_DELETE, 0, key_len, 0, 0);
smart_string_appendl(&(request->sendbuf.value), (const char *)&header, sizeof(header));
smart_string_appendl(&(request->sendbuf.value), key, key_len);
@@ -659,7 +704,6 @@ static void mmc_binary_mutate(mmc_request_t *request, zval *zkey, const char *ke
else {
/* server replies with NOT_FOUND if exptime ~0 and key doesn't exist */
header.expiration = ~(uint32_t)0;
header.expiration = htonl(0x00000e10);
}
/* mutate request is 43 bytes */

View File

@@ -41,6 +41,24 @@
ZEND_DECLARE_MODULE_GLOBALS(memcache)
#if PHP_VERSION_ID >= 80000
#define mmc_string_concat2 zend_string_concat2
#else
static zend_string* mmc_string_concat2(
const char *str1, size_t str1_len,
const char *str2, size_t str2_len)
{
size_t len = str1_len + str2_len;
zend_string *res = zend_string_alloc(len, 0);
memcpy(ZSTR_VAL(res), str1, str1_len);
memcpy(ZSTR_VAL(res) + str1_len, str2, str2_len);
ZSTR_VAL(res)[len] = '\0';
return res;
}
#endif
MMC_POOL_INLINE void mmc_buffer_alloc(mmc_buffer_t *buffer, unsigned int size) /*
ensures space for an additional size bytes {{{ */
{
@@ -407,6 +425,7 @@ int mmc_pack_value(mmc_pool_t *pool, mmc_buffer_t *buffer, zval *value, unsigned
PHP_VAR_SERIALIZE_DESTROY(value_hash);
if (!buf.s) {
zval_dtor(&value_copy);
php_error_docref(NULL, E_WARNING, "Failed to serialize value");
return MMC_REQUEST_FAILURE;
}
@@ -734,7 +753,7 @@ static int mmc_server_connect(mmc_pool_t *pool, mmc_t *mmc, mmc_stream_t *io, in
/* check connection and extract socket for select() purposes */
if (!io->stream || php_stream_cast(io->stream, PHP_STREAM_AS_FD_FOR_SELECT, (void **)&fd, 1) != SUCCESS) {
if (errstr != NULL) {
zend_string* error = zend_string_concat2(
zend_string* error = mmc_string_concat2(
"Connection failed: ", sizeof("Connection failed: ") - 1,
ZSTR_VAL(errstr), ZSTR_LEN(errstr));

View File

@@ -47,7 +47,7 @@
/*
* Mac OS X has no MSG_NOSIGNAL but >= 10.2 comes with SO_NOSIGPIPE which is a setsockopt() option
* and not a send() parameter as MSG_NOSIGNAL. OpenBSD has none of the options so we need to ignore
* and not a send() parameter as MSG_NOSIGNAL. OpenBSD has none of the options so we need to ignore
* SIGPIPE events
*/
#ifndef MSG_NOSIGNAL
@@ -285,7 +285,7 @@ typedef struct mmc_protocol {
mmc_protocol_flush flush;
mmc_protocol_version version;
mmc_protocol_stats stats;
mmc_protocol_set_sasl_auth_data set_sasl_auth_data;
} mmc_protocol_t;
@@ -415,15 +415,15 @@ ZEND_BEGIN_MODULE_GLOBALS(memcache)
long compress_threshold;
long lock_timeout;
char *session_key_prefix;
char *session_prefix_host_key;
char *session_prefix_host_key_remove_www;
char *session_prefix_host_key_remove_subdomain;
zend_bool session_prefix_host_key;
zend_bool session_prefix_host_key_remove_www;
zend_bool session_prefix_host_key_remove_subdomain;
char *session_prefix_static_key;
char *session_save_path;
char *key_prefix;
char *prefix_host_key;
char *prefix_host_key_remove_www;
char *prefix_host_key_remove_subdomain;
zend_bool prefix_host_key;
zend_bool prefix_host_key_remove_www;
zend_bool prefix_host_key_remove_subdomain;
char *prefix_static_key;
ZEND_END_MODULE_GLOBALS(memcache)

View File

@@ -362,12 +362,12 @@ PS_READ_FUNC(memcache)
if (skip_servers.len == pool->num_servers && skip_servers.len < MEMCACHE_G(session_redundancy)) {
*val = ZSTR_EMPTY_ALLOC();
mmc_queue_free(&skip_servers);
zval_ptr_dtor(&dataresult);
return SUCCESS;
}
}
else {
zval_dtor(&dataresult);
/* if missing lock, back off and retry same server */
last_index = prev_index;
usleep(timeout);

View File

@@ -1,7 +1,10 @@
--TEST--
memcache_set() function
--SKIPIF--
<?php include 'connect.inc'; ?>
<?php
if (PHP_VERSION_ID < 80000)
die('skip php 8+ only');
include 'connect.inc';
--FILE--
<?php

47
tests/001b.phpt Normal file
View File

@@ -0,0 +1,47 @@
--TEST--
memcache_set() function
--SKIPIF--
<?php
if (PHP_VERSION_ID >= 80000)
die('skip php prior to 8 only');
include 'connect.inc';
--FILE--
<?php
include 'connect.inc';
$value = new stdClass;
$value->plain_attribute = 'value';
$value->array_attribute = array('test1', 'test2');
memcache_set($memcache, 'test_key', $value, false, 10);
$key = 123;
$value = 123;
memcache_set($memcache, $key, $value, false, 10);
var_dump($key);
var_dump($value);
try {
memcache_set($memcache, $key);
} catch (ArgumentCountError $e) {
echo "{$e->getMessage()}\n";
}
try {
$memcache->set($key);
} catch (ArgumentCountError $e) {
echo "{$e->getMessage()}\n";
}
echo "Done\n";
?>
--EXPECTF--
int(123)
int(123)
Warning: %s parameter%s
Warning: %s parameter%s
Done

View File

@@ -1,7 +1,10 @@
--TEST--
memcache_add_server()
--SKIPIF--
<?php include 'connect.inc'; if (!isset($host2)) die('skip $host2 not set'); ?>
<?php
if (PHP_VERSION_ID < 80000)
die('skip php 8+ only');
include 'connect.inc'; if (!isset($host2)) die('skip $host2 not set'); ?>
--FILE--
<?php

38
tests/019b.phpt Normal file
View File

@@ -0,0 +1,38 @@
--TEST--
memcache_add_server()
--SKIPIF--
<?php
if (PHP_VERSION_ID >= 80000)
die('skip php prior to 8 only');
include 'connect.inc'; if (!isset($host2)) die('skip $host2 not set'); ?>
--FILE--
<?php
include 'connect.inc';
var_dump(memcache_add_server($memcache, $host2, $port2));
var_dump(memcache_add_server($memcache, $nonExistingHost, $nonExistingPort));
try {
var_dump(memcache_add_server(new stdclass, $host2, $port2));
} catch (TypeError $e) {
echo "{$e->getMessage()}\n";
}
try {
var_dump(memcache_add_server($memcache, new stdclass, array()));
} catch (TypeError $e) {
echo "{$e->getMessage()}\n";
}
echo "Done\n";
?>
--EXPECTF--
bool(true)
bool(true)
Argument 1 passed to memcache_add_server() must be an instance of MemcachePool, instance of stdClass given
Warning: memcache_add_server() expects parameter 2 to be string, object given in %s on line %d
NULL
Done

View File

@@ -1,7 +1,10 @@
--TEST--
memcache_get_extended_stats()
--SKIPIF--
<?php include 'connect.inc'; if (!isset($host2)) die('skip $host2 not set'); if (ini_get('memcache.protocol') == 'binary') die('skip binary protocol does not support stats'); ?>
<?php
if (PHP_VERSION_ID < 80000)
die('skip php 8+ only');
include 'connect.inc'; if (!isset($host2)) die('skip $host2 not set'); if (ini_get('memcache.protocol') == 'binary') die('skip binary protocol does not support stats');
--FILE--
<?php

46
tests/022b.phpt Normal file
View File

@@ -0,0 +1,46 @@
--TEST--
memcache_get_extended_stats()
--SKIPIF--
<?php
if (PHP_VERSION_ID >= 80000)
die('skip php prior to 8 only');
include 'connect.inc'; if (!isset($host2)) die('skip $host2 not set'); if (ini_get('memcache.protocol') == 'binary') die('skip binary protocol does not support stats');
--FILE--
<?php
include 'connect.inc';
$memcache = new Memcache();
memcache_add_server($memcache, $nonExistingHost, $nonExistingPort);
memcache_add_server($memcache, $host, $port);
memcache_add_server($memcache, $host2, $port2);
$result1 = @memcache_get_stats($memcache);
$result2 = @memcache_get_extended_stats($memcache);
try {
var_dump(memcache_get_extended_stats(array()));
} catch (TypeError $e) {
echo "{$e->getMessage()}\n";
}
try {
var_dump(memcache_get_extended_stats(new stdClass));
} catch (TypeError $e) {
echo "{$e->getMessage()}\n";
}
var_dump($result1['pid']);
var_dump(count($result2));
var_dump($result2["$host:$port"]['pid']);
var_dump($result2["$host2:$port2"]['pid']);
var_dump($result2["$nonExistingHost:$nonExistingPort"]);
?>
--EXPECTF--
Argument 1 passed to memcache_get_extended_stats() must be an instance of MemcachePool, array given
Argument 1 passed to memcache_get_extended_stats() must be an instance of MemcachePool, instance of stdClass given
string(%d) "%d"
int(3)
string(%d) "%d"
string(%d) "%d"
bool(false)

View File

@@ -1,7 +1,10 @@
--TEST--
memcache_close(), memcache_get()
--SKIPIF--
<?php include 'connect.inc'; if (!isset($host2)) die('skip $host2 not set'); ?>
<?php
if (PHP_VERSION_ID < 80000)
die('skip php 8+ only');
include 'connect.inc'; if (!isset($host2)) die('skip $host2 not set'); ?>
--FILE--
<?php

59
tests/024b.phpt Normal file
View File

@@ -0,0 +1,59 @@
--TEST--
memcache_close(), memcache_get()
--SKIPIF--
<?php
if (PHP_VERSION_ID >= 80000)
die('skip php prior to 8 only');
include 'connect.inc'; if (!isset($host2)) die('skip $host2 not set'); ?>
--FILE--
<?php
include 'connect.inc';
memcache_add_server($memcache, $host2, $port2);
memcache_add_server($memcache, $nonExistingHost, $nonExistingPort);
$result1 = memcache_close($memcache);
var_dump($result1);
$memcache = new Memcache();
$result2 = $memcache->connect($host, $port);
$result3 = memcache_set($memcache, 'test_key', 'test', false, 1);
$result4 = memcache_close($memcache);
// This will fail since all servers have been removed
$result5 = memcache_get($memcache, 'test_key');
var_dump($result2);
var_dump($result3);
var_dump($result4);
var_dump($result5);
var_dump(memcache_close($memcache));
var_dump(memcache_close($memcache));
try {
var_dump(memcache_close(new stdClass));
} catch (TypeError $e) {
echo "{$e->getMessage()}\n";
}
try {
var_dump(memcache_close(""));
} catch (TypeError $e) {
echo "{$e->getMessage()}\n";
}
echo "Done\n";
?>
--EXPECTF--
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
bool(true)
bool(true)
Argument 1 passed to memcache_close() must be an instance of MemcachePool, instance of stdClass given
Argument 1 passed to memcache_close() must be an instance of MemcachePool, string given
Done

View File

@@ -1,7 +1,10 @@
--TEST--
memcache_set_compress_threshold()
--SKIPIF--
<?php include 'connect.inc'; ?>
<?php
if (PHP_VERSION_ID < 80000)
die('skip php 8+ only');
include 'connect.inc'; ?>
--FILE--
<?php

71
tests/027b.phpt Normal file
View File

@@ -0,0 +1,71 @@
--TEST--
memcache_set_compress_threshold()
--SKIPIF--
<?php
if (PHP_VERSION_ID >= 80000)
die('skip php prior to 8 only');
include 'connect.inc'; ?>
--FILE--
<?php
include 'connect.inc';
$var = str_repeat('abc', 5000);
memcache_set_compress_threshold($memcache, 10000);
$result1 = memcache_set($memcache, 'non_existing_test_key', $var, 0, 1);
$result2 = memcache_get($memcache, 'non_existing_test_key');
var_dump($result1);
var_dump(strlen($result2));
memcache_set_compress_threshold($memcache, 10000, 0);
$result3 = memcache_set($memcache, 'non_existing_test_key', $var, 0, 1);
memcache_set_compress_threshold($memcache, 10000, 1);
$result4 = memcache_set($memcache, 'non_existing_test_key', $var, 0, 1);
var_dump($result3);
var_dump($result4);
$result5 = memcache_set($memcache, 'non_existing_test_key', 'abc', MEMCACHE_COMPRESSED, 1);
$result6 = memcache_get($memcache, 'non_existing_test_key');
var_dump($result5);
var_dump($result6);
try {
var_dump(memcache_set_compress_threshold(array(), 10000, 0));
} catch (TypeError $e) {
echo "{$e->getMessage()}\n";
}
var_dump(memcache_set_compress_threshold($memcache, -1, -1));
var_dump(memcache_set_compress_threshold($memcache, 1, -1));
var_dump(memcache_set_compress_threshold($memcache, -1, 1));
try {
var_dump(memcache_set_compress_threshold(new stdClass, 1, 1));
} catch (TypeError $e) {
echo "{$e->getMessage()}\n";
}
echo "Done\n";
?>
--EXPECTF--
bool(true)
int(15000)
bool(true)
bool(true)
bool(true)
string(3) "abc"
Argument 1 passed to memcache_set_compress_threshold() must be an instance of MemcachePool, array given
Warning: memcache_set_compress_threshold()%s threshold must be a positive integer in %s on line %d
bool(false)
Warning: memcache_set_compress_threshold()%s min_savings must be a float in the 0..1 range in %s on line %d
bool(false)
Warning: memcache_set_compress_threshold()%s threshold must be a positive integer in %s on line %d
bool(false)
Argument 1 passed to memcache_set_compress_threshold() must be an instance of MemcachePool, instance of stdClass given
Done

815
tests/059.phpt Normal file
View File

@@ -0,0 +1,815 @@
--TEST--
Reflection
--SKIPIF--
<?php
if (PHP_VERSION_ID < 80000)
die('skip php 8+ only');
--FILE--
<?php
echo new ReflectionClass('MemcachePool');
echo new ReflectionClass('Memcache');
echo new ReflectionFunction('memcache_connect');
echo new ReflectionFunction('memcache_pconnect');
echo new ReflectionFunction('memcache_add_server');
echo new ReflectionFunction('memcache_set_server_params');
echo new ReflectionFunction('memcache_set_failure_callback');
echo new ReflectionFunction('memcache_get_server_status');
echo new ReflectionFunction('memcache_get_version');
echo new ReflectionFunction('memcache_add');
echo new ReflectionFunction('memcache_set');
echo new ReflectionFunction('memcache_replace');
echo new ReflectionFunction('memcache_cas');
echo new ReflectionFunction('memcache_append');
echo new ReflectionFunction('memcache_prepend');
echo new ReflectionFunction('memcache_get');
echo new ReflectionFunction('memcache_delete');
echo new ReflectionFunction('memcache_debug');
echo new ReflectionFunction('memcache_get_stats');
echo new ReflectionFunction('memcache_get_extended_stats');
echo new ReflectionFunction('memcache_set_compress_threshold');
echo new ReflectionFunction('memcache_increment');
echo new ReflectionFunction('memcache_decrement');
echo new ReflectionFunction('memcache_close');
echo new ReflectionFunction('memcache_flush');
echo new ReflectionFunction('memcache_set_sasl_auth_data');
--EXPECT--
Class [ <internal:memcache> class MemcachePool ] {
- Constants [0] {
}
- Static properties [0] {
}
- Static methods [0] {
}
- Properties [0] {
}
- Methods [23] {
Method [ <internal:memcache> public method connect ] {
- Parameters [7] {
Parameter #0 [ <required> $host ]
Parameter #1 [ <optional> $tcp_port = <default> ]
Parameter #2 [ <optional> $udp_port = <default> ]
Parameter #3 [ <optional> $persistent = <default> ]
Parameter #4 [ <optional> $weight = <default> ]
Parameter #5 [ <optional> $timeout = <default> ]
Parameter #6 [ <optional> $retry_interval = <default> ]
}
}
Method [ <internal:memcache> public method addserver ] {
- Parameters [8] {
Parameter #0 [ <required> $host ]
Parameter #1 [ <optional> $tcp_port = <default> ]
Parameter #2 [ <optional> $udp_port = <default> ]
Parameter #3 [ <optional> $persistent = <default> ]
Parameter #4 [ <optional> $weight = <default> ]
Parameter #5 [ <optional> $timeout = <default> ]
Parameter #6 [ <optional> $retry_interval = <default> ]
Parameter #7 [ <optional> $status = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method setserverparams ] {
- Parameters [6] {
Parameter #0 [ <required> string $host ]
Parameter #1 [ <optional> int $tcp_port = <default> ]
Parameter #2 [ <optional> float $timeout = <default> ]
Parameter #3 [ <optional> int $retry_interval = <default> ]
Parameter #4 [ <optional> bool $status = <default> ]
Parameter #5 [ <optional> $failure_callback = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method setfailurecallback ] {
- Parameters [1] {
Parameter #0 [ <required> ?callable $failure_callback ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method getserverstatus ] {
- Parameters [2] {
Parameter #0 [ <required> string $host ]
Parameter #1 [ <optional> int $tcp_port = <default> ]
}
- Return [ int|bool ]
}
Method [ <internal:memcache> public method findserver ] {
- Parameters [1] {
Parameter #0 [ <required> string $key ]
}
- Return [ string|bool ]
}
Method [ <internal:memcache> public method getversion ] {
- Parameters [0] {
}
- Return [ string|bool ]
}
Method [ <internal:memcache> public method add ] {
- Parameters [5] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> mixed $value = <default> ]
Parameter #2 [ <optional> int $flags = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
Parameter #4 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method set ] {
- Parameters [5] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> mixed $value = <default> ]
Parameter #2 [ <optional> int $flags = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
Parameter #4 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method replace ] {
- Parameters [5] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> mixed $value = <default> ]
Parameter #2 [ <optional> int $flags = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
Parameter #4 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method cas ] {
- Parameters [5] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> mixed $value = <default> ]
Parameter #2 [ <optional> int $flags = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
Parameter #4 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method append ] {
- Parameters [5] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> mixed $value = <default> ]
Parameter #2 [ <optional> int $flags = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
Parameter #4 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method prepend ] {
- Parameters [5] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> mixed $value = <default> ]
Parameter #2 [ <optional> int $flags = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
Parameter #4 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method get ] {
- Parameters [3] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> mixed &$flags = <default> ]
Parameter #2 [ <optional> mixed &$cas = <default> ]
}
- Return [ mixed ]
}
Method [ <internal:memcache> public method delete ] {
- Parameters [2] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> int $exptime = <default> ]
}
- Return [ array|bool ]
}
Method [ <internal:memcache> public method getstats ] {
- Parameters [3] {
Parameter #0 [ <optional> string $type = <default> ]
Parameter #1 [ <optional> int $slabid = <default> ]
Parameter #2 [ <optional> int $limit = <default> ]
}
- Return [ array|bool ]
}
Method [ <internal:memcache> public method getextendedstats ] {
- Parameters [3] {
Parameter #0 [ <optional> string $type = <default> ]
Parameter #1 [ <optional> int $slabid = <default> ]
Parameter #2 [ <optional> int $limit = <default> ]
}
- Return [ array|bool ]
}
Method [ <internal:memcache> public method setcompressthreshold ] {
- Parameters [2] {
Parameter #0 [ <required> int $threshold ]
Parameter #1 [ <optional> float $min_savings = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method increment ] {
- Parameters [4] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> int $value = <default> ]
Parameter #2 [ <optional> int $defval = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
}
- Return [ array|int|bool ]
}
Method [ <internal:memcache> public method decrement ] {
- Parameters [4] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> int $value = <default> ]
Parameter #2 [ <optional> int $defval = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
}
- Return [ array|int|bool ]
}
Method [ <internal:memcache> public method close ] {
- Parameters [0] {
}
- Return [ bool ]
}
Method [ <internal:memcache> public method flush ] {
- Parameters [1] {
Parameter #0 [ <optional> int $delay = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method setSaslAuthData ] {
- Parameters [2] {
Parameter #0 [ <required> string $username ]
Parameter #1 [ <required> string $password ]
}
- Return [ bool ]
}
}
}
Class [ <internal:memcache> class Memcache extends MemcachePool ] {
- Constants [0] {
}
- Static properties [0] {
}
- Static methods [0] {
}
- Properties [0] {
}
- Methods [24] {
Method [ <internal:memcache, overwrites MemcachePool, prototype MemcachePool> public method connect ] {
- Parameters [8] {
Parameter #0 [ <required> $host ]
Parameter #1 [ <optional> $port = <default> ]
Parameter #2 [ <optional> $timeout = <default> ]
Parameter #3 [ <optional> $unused4 = <default> ]
Parameter #4 [ <optional> $unused5 = <default> ]
Parameter #5 [ <optional> $unused6 = <default> ]
Parameter #6 [ <optional> $unused7 = <default> ]
Parameter #7 [ <optional> $unugsed8 = <default> ]
}
}
Method [ <internal:memcache> public method pconnect ] {
- Parameters [8] {
Parameter #0 [ <required> $host ]
Parameter #1 [ <optional> $port = <default> ]
Parameter #2 [ <optional> $timeout = <default> ]
Parameter #3 [ <optional> $unused4 = <default> ]
Parameter #4 [ <optional> $unused5 = <default> ]
Parameter #5 [ <optional> $unused6 = <default> ]
Parameter #6 [ <optional> $unused7 = <default> ]
Parameter #7 [ <optional> $unugsed8 = <default> ]
}
}
Method [ <internal:memcache, overwrites MemcachePool, prototype MemcachePool> public method addserver ] {
- Parameters [8] {
Parameter #0 [ <required> $host ]
Parameter #1 [ <optional> $tcp_port = <default> ]
Parameter #2 [ <optional> $persistent = <default> ]
Parameter #3 [ <optional> $weight = <default> ]
Parameter #4 [ <optional> $timeout = <default> ]
Parameter #5 [ <optional> $retry_interval = <default> ]
Parameter #6 [ <optional> $status = <default> ]
Parameter #7 [ <optional> $failure_callback = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method setserverparams ] {
- Parameters [6] {
Parameter #0 [ <required> string $host ]
Parameter #1 [ <optional> int $tcp_port = <default> ]
Parameter #2 [ <optional> float $timeout = <default> ]
Parameter #3 [ <optional> int $retry_interval = <default> ]
Parameter #4 [ <optional> bool $status = <default> ]
Parameter #5 [ <optional> $failure_callback = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method setfailurecallback ] {
- Parameters [1] {
Parameter #0 [ <required> ?callable $failure_callback ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method getserverstatus ] {
- Parameters [2] {
Parameter #0 [ <required> string $host ]
Parameter #1 [ <optional> int $tcp_port = <default> ]
}
- Return [ int|bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method findserver ] {
- Parameters [1] {
Parameter #0 [ <required> string $key ]
}
- Return [ string|bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method getversion ] {
- Parameters [0] {
}
- Return [ string|bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method add ] {
- Parameters [5] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> mixed $value = <default> ]
Parameter #2 [ <optional> int $flags = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
Parameter #4 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method set ] {
- Parameters [5] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> mixed $value = <default> ]
Parameter #2 [ <optional> int $flags = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
Parameter #4 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method replace ] {
- Parameters [5] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> mixed $value = <default> ]
Parameter #2 [ <optional> int $flags = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
Parameter #4 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method cas ] {
- Parameters [5] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> mixed $value = <default> ]
Parameter #2 [ <optional> int $flags = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
Parameter #4 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method append ] {
- Parameters [5] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> mixed $value = <default> ]
Parameter #2 [ <optional> int $flags = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
Parameter #4 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method prepend ] {
- Parameters [5] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> mixed $value = <default> ]
Parameter #2 [ <optional> int $flags = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
Parameter #4 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method get ] {
- Parameters [3] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> mixed &$flags = <default> ]
Parameter #2 [ <optional> mixed &$cas = <default> ]
}
- Return [ mixed ]
}
Method [ <internal:memcache, inherits MemcachePool> public method delete ] {
- Parameters [2] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> int $exptime = <default> ]
}
- Return [ array|bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method getstats ] {
- Parameters [3] {
Parameter #0 [ <optional> string $type = <default> ]
Parameter #1 [ <optional> int $slabid = <default> ]
Parameter #2 [ <optional> int $limit = <default> ]
}
- Return [ array|bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method getextendedstats ] {
- Parameters [3] {
Parameter #0 [ <optional> string $type = <default> ]
Parameter #1 [ <optional> int $slabid = <default> ]
Parameter #2 [ <optional> int $limit = <default> ]
}
- Return [ array|bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method setcompressthreshold ] {
- Parameters [2] {
Parameter #0 [ <required> int $threshold ]
Parameter #1 [ <optional> float $min_savings = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method increment ] {
- Parameters [4] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> int $value = <default> ]
Parameter #2 [ <optional> int $defval = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
}
- Return [ array|int|bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method decrement ] {
- Parameters [4] {
Parameter #0 [ <required> array|string $key ]
Parameter #1 [ <optional> int $value = <default> ]
Parameter #2 [ <optional> int $defval = <default> ]
Parameter #3 [ <optional> int $exptime = <default> ]
}
- Return [ array|int|bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method close ] {
- Parameters [0] {
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method flush ] {
- Parameters [1] {
Parameter #0 [ <optional> int $delay = <default> ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method setSaslAuthData ] {
- Parameters [2] {
Parameter #0 [ <required> string $username ]
Parameter #1 [ <required> string $password ]
}
- Return [ bool ]
}
}
}
Function [ <internal:memcache> function memcache_connect ] {
- Parameters [8] {
Parameter #0 [ <required> $host ]
Parameter #1 [ <optional> $port = <default> ]
Parameter #2 [ <optional> $timeout = <default> ]
Parameter #3 [ <optional> $unused4 = <default> ]
Parameter #4 [ <optional> $unused5 = <default> ]
Parameter #5 [ <optional> $unused6 = <default> ]
Parameter #6 [ <optional> $unused7 = <default> ]
Parameter #7 [ <optional> $unugsed8 = <default> ]
}
}
Function [ <internal:memcache> function memcache_pconnect ] {
- Parameters [8] {
Parameter #0 [ <required> $host ]
Parameter #1 [ <optional> $port = <default> ]
Parameter #2 [ <optional> $timeout = <default> ]
Parameter #3 [ <optional> $unused4 = <default> ]
Parameter #4 [ <optional> $unused5 = <default> ]
Parameter #5 [ <optional> $unused6 = <default> ]
Parameter #6 [ <optional> $unused7 = <default> ]
Parameter #7 [ <optional> $unugsed8 = <default> ]
}
}
Function [ <internal:memcache> function memcache_add_server ] {
- Parameters [10] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> $host ]
Parameter #2 [ <optional> $port = <default> ]
Parameter #3 [ <optional> $tcp_port = <default> ]
Parameter #4 [ <optional> $persistent = <default> ]
Parameter #5 [ <optional> $weight = <default> ]
Parameter #6 [ <optional> $timeout = <default> ]
Parameter #7 [ <optional> $retry_interval = <default> ]
Parameter #8 [ <optional> $status = <default> ]
Parameter #9 [ <optional> $failure_callback = <default> ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_set_server_params ] {
- Parameters [7] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> string $host ]
Parameter #2 [ <optional> int $tcp_port = <default> ]
Parameter #3 [ <optional> float $timeout = <default> ]
Parameter #4 [ <optional> int $retry_interval = <default> ]
Parameter #5 [ <optional> bool $status = <default> ]
Parameter #6 [ <optional> $failure_callback = <default> ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_set_failure_callback ] {
- Parameters [2] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> ?callable $failure_callback ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_get_server_status ] {
- Parameters [3] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> string $host ]
Parameter #2 [ <optional> int $tcp_port = <default> ]
}
- Return [ int|bool ]
}
Function [ <internal:memcache> function memcache_get_version ] {
- Parameters [1] {
Parameter #0 [ <required> MemcachePool $memcache ]
}
- Return [ string|bool ]
}
Function [ <internal:memcache> function memcache_add ] {
- Parameters [6] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> array|string $key ]
Parameter #2 [ <optional> mixed $value = <default> ]
Parameter #3 [ <optional> int $flags = <default> ]
Parameter #4 [ <optional> int $exptime = <default> ]
Parameter #5 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_set ] {
- Parameters [6] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> array|string $key ]
Parameter #2 [ <optional> mixed $value = <default> ]
Parameter #3 [ <optional> int $flags = <default> ]
Parameter #4 [ <optional> int $exptime = <default> ]
Parameter #5 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_replace ] {
- Parameters [6] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> array|string $key ]
Parameter #2 [ <optional> mixed $value = <default> ]
Parameter #3 [ <optional> int $flags = <default> ]
Parameter #4 [ <optional> int $exptime = <default> ]
Parameter #5 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_cas ] {
- Parameters [6] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> array|string $key ]
Parameter #2 [ <optional> mixed $value = <default> ]
Parameter #3 [ <optional> int $flags = <default> ]
Parameter #4 [ <optional> int $exptime = <default> ]
Parameter #5 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_append ] {
- Parameters [6] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> array|string $key ]
Parameter #2 [ <optional> mixed $value = <default> ]
Parameter #3 [ <optional> int $flags = <default> ]
Parameter #4 [ <optional> int $exptime = <default> ]
Parameter #5 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_prepend ] {
- Parameters [6] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> array|string $key ]
Parameter #2 [ <optional> mixed $value = <default> ]
Parameter #3 [ <optional> int $flags = <default> ]
Parameter #4 [ <optional> int $exptime = <default> ]
Parameter #5 [ <optional> int $cas = <default> ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_get ] {
- Parameters [4] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> $key ]
Parameter #2 [ <optional> &$flags = <default> ]
Parameter #3 [ <optional> &$cas = <default> ]
}
- Return [ mixed ]
}
Function [ <internal:memcache> function memcache_delete ] {
- Parameters [3] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> $key ]
Parameter #2 [ <optional> $exptime = <default> ]
}
- Return [ array|bool ]
}
Function [ <internal:memcache> function memcache_debug ] {
- Parameters [1] {
Parameter #0 [ <required> $on_off ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_get_stats ] {
- Parameters [4] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <optional> string $type = <default> ]
Parameter #2 [ <optional> int $slabid = <default> ]
Parameter #3 [ <optional> int $limit = <default> ]
}
- Return [ array|bool ]
}
Function [ <internal:memcache> function memcache_get_extended_stats ] {
- Parameters [4] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <optional> string $type = <default> ]
Parameter #2 [ <optional> int $slabid = <default> ]
Parameter #3 [ <optional> int $limit = <default> ]
}
- Return [ array|bool ]
}
Function [ <internal:memcache> function memcache_set_compress_threshold ] {
- Parameters [3] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> int $threshold ]
Parameter #2 [ <optional> float $min_savings = <default> ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_increment ] {
- Parameters [5] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> array|string $key ]
Parameter #2 [ <optional> int $value = <default> ]
Parameter #3 [ <optional> int $defval = <default> ]
Parameter #4 [ <optional> int $exptime = <default> ]
}
- Return [ array|int|bool ]
}
Function [ <internal:memcache> function memcache_decrement ] {
- Parameters [5] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> array|string $key ]
Parameter #2 [ <optional> int $value = <default> ]
Parameter #3 [ <optional> int $defval = <default> ]
Parameter #4 [ <optional> int $exptime = <default> ]
}
- Return [ array|int|bool ]
}
Function [ <internal:memcache> function memcache_close ] {
- Parameters [1] {
Parameter #0 [ <required> MemcachePool $memcache ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_flush ] {
- Parameters [2] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <optional> int $delay = <default> ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_set_sasl_auth_data ] {
- Parameters [3] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> string $username ]
Parameter #2 [ <required> string $password ]
}
- Return [ bool ]
}

789
tests/059b.phpt Normal file
View File

@@ -0,0 +1,789 @@
--TEST--
Reflection
--SKIPIF--
<?php
if (PHP_VERSION_ID >= 80000)
die('skip php prior to 8 only');
--FILE--
<?php
echo new ReflectionClass('MemcachePool');
echo new ReflectionClass('Memcache');
echo new ReflectionFunction('memcache_connect');
echo new ReflectionFunction('memcache_pconnect');
echo new ReflectionFunction('memcache_add_server');
echo new ReflectionFunction('memcache_set_server_params');
echo new ReflectionFunction('memcache_set_failure_callback');
echo new ReflectionFunction('memcache_get_server_status');
echo new ReflectionFunction('memcache_get_version');
echo new ReflectionFunction('memcache_add');
echo new ReflectionFunction('memcache_set');
echo new ReflectionFunction('memcache_replace');
echo new ReflectionFunction('memcache_cas');
echo new ReflectionFunction('memcache_append');
echo new ReflectionFunction('memcache_prepend');
echo new ReflectionFunction('memcache_get');
echo new ReflectionFunction('memcache_delete');
echo new ReflectionFunction('memcache_debug');
echo new ReflectionFunction('memcache_get_stats');
echo new ReflectionFunction('memcache_get_extended_stats');
echo new ReflectionFunction('memcache_set_compress_threshold');
echo new ReflectionFunction('memcache_increment');
echo new ReflectionFunction('memcache_decrement');
echo new ReflectionFunction('memcache_close');
echo new ReflectionFunction('memcache_flush');
echo new ReflectionFunction('memcache_set_sasl_auth_data');
--EXPECT--
Class [ <internal:memcache> class MemcachePool ] {
- Constants [0] {
}
- Static properties [0] {
}
- Static methods [0] {
}
- Properties [0] {
}
- Methods [23] {
Method [ <internal:memcache> public method connect ] {
- Parameters [7] {
Parameter #0 [ <required> $host ]
Parameter #1 [ <optional> $tcp_port ]
Parameter #2 [ <optional> $udp_port ]
Parameter #3 [ <optional> $persistent ]
Parameter #4 [ <optional> $weight ]
Parameter #5 [ <optional> $timeout ]
Parameter #6 [ <optional> $retry_interval ]
}
}
Method [ <internal:memcache> public method addserver ] {
- Parameters [8] {
Parameter #0 [ <required> $host ]
Parameter #1 [ <optional> $tcp_port ]
Parameter #2 [ <optional> $udp_port ]
Parameter #3 [ <optional> $persistent ]
Parameter #4 [ <optional> $weight ]
Parameter #5 [ <optional> $timeout ]
Parameter #6 [ <optional> $retry_interval ]
Parameter #7 [ <optional> $status ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method setserverparams ] {
- Parameters [6] {
Parameter #0 [ <required> string $host ]
Parameter #1 [ <optional> int $tcp_port ]
Parameter #2 [ <optional> float $timeout ]
Parameter #3 [ <optional> int $retry_interval ]
Parameter #4 [ <optional> bool $status ]
Parameter #5 [ <optional> $failure_callback ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method setfailurecallback ] {
- Parameters [1] {
Parameter #0 [ <required> callable or NULL $failure_callback ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method getserverstatus ] {
- Parameters [2] {
Parameter #0 [ <required> string $host ]
Parameter #1 [ <optional> int $tcp_port ]
}
}
Method [ <internal:memcache> public method findserver ] {
- Parameters [1] {
Parameter #0 [ <required> string $key ]
}
}
Method [ <internal:memcache> public method getversion ] {
- Parameters [0] {
}
}
Method [ <internal:memcache> public method add ] {
- Parameters [5] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> $value ]
Parameter #2 [ <optional> int $flags ]
Parameter #3 [ <optional> int $exptime ]
Parameter #4 [ <optional> int $cas ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method set ] {
- Parameters [5] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> $value ]
Parameter #2 [ <optional> int $flags ]
Parameter #3 [ <optional> int $exptime ]
Parameter #4 [ <optional> int $cas ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method replace ] {
- Parameters [5] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> $value ]
Parameter #2 [ <optional> int $flags ]
Parameter #3 [ <optional> int $exptime ]
Parameter #4 [ <optional> int $cas ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method cas ] {
- Parameters [5] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> $value ]
Parameter #2 [ <optional> int $flags ]
Parameter #3 [ <optional> int $exptime ]
Parameter #4 [ <optional> int $cas ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method append ] {
- Parameters [5] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> $value ]
Parameter #2 [ <optional> int $flags ]
Parameter #3 [ <optional> int $exptime ]
Parameter #4 [ <optional> int $cas ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method prepend ] {
- Parameters [5] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> $value ]
Parameter #2 [ <optional> int $flags ]
Parameter #3 [ <optional> int $exptime ]
Parameter #4 [ <optional> int $cas ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method get ] {
- Parameters [3] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> &$flags ]
Parameter #2 [ <optional> &$cas ]
}
}
Method [ <internal:memcache> public method delete ] {
- Parameters [2] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> int $exptime ]
}
}
Method [ <internal:memcache> public method getstats ] {
- Parameters [3] {
Parameter #0 [ <optional> string $type ]
Parameter #1 [ <optional> int $slabid ]
Parameter #2 [ <optional> int $limit ]
}
}
Method [ <internal:memcache> public method getextendedstats ] {
- Parameters [3] {
Parameter #0 [ <optional> string $type ]
Parameter #1 [ <optional> int $slabid ]
Parameter #2 [ <optional> int $limit ]
}
}
Method [ <internal:memcache> public method setcompressthreshold ] {
- Parameters [2] {
Parameter #0 [ <required> int $threshold ]
Parameter #1 [ <optional> float $min_savings ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method increment ] {
- Parameters [4] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> int $value ]
Parameter #2 [ <optional> int $defval ]
Parameter #3 [ <optional> int $exptime ]
}
}
Method [ <internal:memcache> public method decrement ] {
- Parameters [4] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> int $value ]
Parameter #2 [ <optional> int $defval ]
Parameter #3 [ <optional> int $exptime ]
}
}
Method [ <internal:memcache> public method close ] {
- Parameters [0] {
}
- Return [ bool ]
}
Method [ <internal:memcache> public method flush ] {
- Parameters [1] {
Parameter #0 [ <optional> int $delay ]
}
- Return [ bool ]
}
Method [ <internal:memcache> public method setSaslAuthData ] {
- Parameters [2] {
Parameter #0 [ <required> string $username ]
Parameter #1 [ <required> string $password ]
}
- Return [ bool ]
}
}
}
Class [ <internal:memcache> class Memcache extends MemcachePool ] {
- Constants [0] {
}
- Static properties [0] {
}
- Static methods [0] {
}
- Properties [0] {
}
- Methods [24] {
Method [ <internal:memcache, overwrites MemcachePool, prototype MemcachePool> public method connect ] {
- Parameters [8] {
Parameter #0 [ <required> $host ]
Parameter #1 [ <optional> $port ]
Parameter #2 [ <optional> $timeout ]
Parameter #3 [ <optional> $unused4 ]
Parameter #4 [ <optional> $unused5 ]
Parameter #5 [ <optional> $unused6 ]
Parameter #6 [ <optional> $unused7 ]
Parameter #7 [ <optional> $unugsed8 ]
}
}
Method [ <internal:memcache> public method pconnect ] {
- Parameters [8] {
Parameter #0 [ <required> $host ]
Parameter #1 [ <optional> $port ]
Parameter #2 [ <optional> $timeout ]
Parameter #3 [ <optional> $unused4 ]
Parameter #4 [ <optional> $unused5 ]
Parameter #5 [ <optional> $unused6 ]
Parameter #6 [ <optional> $unused7 ]
Parameter #7 [ <optional> $unugsed8 ]
}
}
Method [ <internal:memcache, overwrites MemcachePool, prototype MemcachePool> public method addserver ] {
- Parameters [8] {
Parameter #0 [ <required> $host ]
Parameter #1 [ <optional> $tcp_port ]
Parameter #2 [ <optional> $persistent ]
Parameter #3 [ <optional> $weight ]
Parameter #4 [ <optional> $timeout ]
Parameter #5 [ <optional> $retry_interval ]
Parameter #6 [ <optional> $status ]
Parameter #7 [ <optional> $failure_callback ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method setserverparams ] {
- Parameters [6] {
Parameter #0 [ <required> string $host ]
Parameter #1 [ <optional> int $tcp_port ]
Parameter #2 [ <optional> float $timeout ]
Parameter #3 [ <optional> int $retry_interval ]
Parameter #4 [ <optional> bool $status ]
Parameter #5 [ <optional> $failure_callback ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method setfailurecallback ] {
- Parameters [1] {
Parameter #0 [ <required> callable or NULL $failure_callback ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method getserverstatus ] {
- Parameters [2] {
Parameter #0 [ <required> string $host ]
Parameter #1 [ <optional> int $tcp_port ]
}
}
Method [ <internal:memcache, inherits MemcachePool> public method findserver ] {
- Parameters [1] {
Parameter #0 [ <required> string $key ]
}
}
Method [ <internal:memcache, inherits MemcachePool> public method getversion ] {
- Parameters [0] {
}
}
Method [ <internal:memcache, inherits MemcachePool> public method add ] {
- Parameters [5] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> $value ]
Parameter #2 [ <optional> int $flags ]
Parameter #3 [ <optional> int $exptime ]
Parameter #4 [ <optional> int $cas ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method set ] {
- Parameters [5] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> $value ]
Parameter #2 [ <optional> int $flags ]
Parameter #3 [ <optional> int $exptime ]
Parameter #4 [ <optional> int $cas ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method replace ] {
- Parameters [5] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> $value ]
Parameter #2 [ <optional> int $flags ]
Parameter #3 [ <optional> int $exptime ]
Parameter #4 [ <optional> int $cas ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method cas ] {
- Parameters [5] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> $value ]
Parameter #2 [ <optional> int $flags ]
Parameter #3 [ <optional> int $exptime ]
Parameter #4 [ <optional> int $cas ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method append ] {
- Parameters [5] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> $value ]
Parameter #2 [ <optional> int $flags ]
Parameter #3 [ <optional> int $exptime ]
Parameter #4 [ <optional> int $cas ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method prepend ] {
- Parameters [5] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> $value ]
Parameter #2 [ <optional> int $flags ]
Parameter #3 [ <optional> int $exptime ]
Parameter #4 [ <optional> int $cas ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method get ] {
- Parameters [3] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> &$flags ]
Parameter #2 [ <optional> &$cas ]
}
}
Method [ <internal:memcache, inherits MemcachePool> public method delete ] {
- Parameters [2] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> int $exptime ]
}
}
Method [ <internal:memcache, inherits MemcachePool> public method getstats ] {
- Parameters [3] {
Parameter #0 [ <optional> string $type ]
Parameter #1 [ <optional> int $slabid ]
Parameter #2 [ <optional> int $limit ]
}
}
Method [ <internal:memcache, inherits MemcachePool> public method getextendedstats ] {
- Parameters [3] {
Parameter #0 [ <optional> string $type ]
Parameter #1 [ <optional> int $slabid ]
Parameter #2 [ <optional> int $limit ]
}
}
Method [ <internal:memcache, inherits MemcachePool> public method setcompressthreshold ] {
- Parameters [2] {
Parameter #0 [ <required> int $threshold ]
Parameter #1 [ <optional> float $min_savings ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method increment ] {
- Parameters [4] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> int $value ]
Parameter #2 [ <optional> int $defval ]
Parameter #3 [ <optional> int $exptime ]
}
}
Method [ <internal:memcache, inherits MemcachePool> public method decrement ] {
- Parameters [4] {
Parameter #0 [ <required> $key ]
Parameter #1 [ <optional> int $value ]
Parameter #2 [ <optional> int $defval ]
Parameter #3 [ <optional> int $exptime ]
}
}
Method [ <internal:memcache, inherits MemcachePool> public method close ] {
- Parameters [0] {
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method flush ] {
- Parameters [1] {
Parameter #0 [ <optional> int $delay ]
}
- Return [ bool ]
}
Method [ <internal:memcache, inherits MemcachePool> public method setSaslAuthData ] {
- Parameters [2] {
Parameter #0 [ <required> string $username ]
Parameter #1 [ <required> string $password ]
}
- Return [ bool ]
}
}
}
Function [ <internal:memcache> function memcache_connect ] {
- Parameters [8] {
Parameter #0 [ <required> $host ]
Parameter #1 [ <optional> $port ]
Parameter #2 [ <optional> $timeout ]
Parameter #3 [ <optional> $unused4 ]
Parameter #4 [ <optional> $unused5 ]
Parameter #5 [ <optional> $unused6 ]
Parameter #6 [ <optional> $unused7 ]
Parameter #7 [ <optional> $unugsed8 ]
}
}
Function [ <internal:memcache> function memcache_pconnect ] {
- Parameters [8] {
Parameter #0 [ <required> $host ]
Parameter #1 [ <optional> $port ]
Parameter #2 [ <optional> $timeout ]
Parameter #3 [ <optional> $unused4 ]
Parameter #4 [ <optional> $unused5 ]
Parameter #5 [ <optional> $unused6 ]
Parameter #6 [ <optional> $unused7 ]
Parameter #7 [ <optional> $unugsed8 ]
}
}
Function [ <internal:memcache> function memcache_add_server ] {
- Parameters [10] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> $host ]
Parameter #2 [ <optional> $port ]
Parameter #3 [ <optional> $tcp_port ]
Parameter #4 [ <optional> $persistent ]
Parameter #5 [ <optional> $weight ]
Parameter #6 [ <optional> $timeout ]
Parameter #7 [ <optional> $retry_interval ]
Parameter #8 [ <optional> $status ]
Parameter #9 [ <optional> $failure_callback ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_set_server_params ] {
- Parameters [7] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> string $host ]
Parameter #2 [ <optional> int $tcp_port ]
Parameter #3 [ <optional> float $timeout ]
Parameter #4 [ <optional> int $retry_interval ]
Parameter #5 [ <optional> bool $status ]
Parameter #6 [ <optional> $failure_callback ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_set_failure_callback ] {
- Parameters [2] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> callable or NULL $failure_callback ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_get_server_status ] {
- Parameters [3] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> string $host ]
Parameter #2 [ <optional> int $tcp_port ]
}
}
Function [ <internal:memcache> function memcache_get_version ] {
- Parameters [1] {
Parameter #0 [ <required> MemcachePool $memcache ]
}
}
Function [ <internal:memcache> function memcache_add ] {
- Parameters [6] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> $key ]
Parameter #2 [ <optional> $value ]
Parameter #3 [ <optional> int $flags ]
Parameter #4 [ <optional> int $exptime ]
Parameter #5 [ <optional> int $cas ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_set ] {
- Parameters [6] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> $key ]
Parameter #2 [ <optional> $value ]
Parameter #3 [ <optional> int $flags ]
Parameter #4 [ <optional> int $exptime ]
Parameter #5 [ <optional> int $cas ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_replace ] {
- Parameters [6] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> $key ]
Parameter #2 [ <optional> $value ]
Parameter #3 [ <optional> int $flags ]
Parameter #4 [ <optional> int $exptime ]
Parameter #5 [ <optional> int $cas ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_cas ] {
- Parameters [6] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> $key ]
Parameter #2 [ <optional> $value ]
Parameter #3 [ <optional> int $flags ]
Parameter #4 [ <optional> int $exptime ]
Parameter #5 [ <optional> int $cas ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_append ] {
- Parameters [6] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> $key ]
Parameter #2 [ <optional> $value ]
Parameter #3 [ <optional> int $flags ]
Parameter #4 [ <optional> int $exptime ]
Parameter #5 [ <optional> int $cas ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_prepend ] {
- Parameters [6] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> $key ]
Parameter #2 [ <optional> $value ]
Parameter #3 [ <optional> int $flags ]
Parameter #4 [ <optional> int $exptime ]
Parameter #5 [ <optional> int $cas ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_get ] {
- Parameters [4] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <optional> $key ]
Parameter #2 [ <optional> &$flags ]
Parameter #3 [ <optional> &$cas ]
}
}
Function [ <internal:memcache> function memcache_delete ] {
- Parameters [3] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> $key ]
Parameter #2 [ <optional> $exptime ]
}
}
Function [ <internal:memcache> function memcache_debug ] {
- Parameters [1] {
Parameter #0 [ <required> $on_off ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_get_stats ] {
- Parameters [4] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <optional> string $type ]
Parameter #2 [ <optional> int $slabid ]
Parameter #3 [ <optional> int $limit ]
}
}
Function [ <internal:memcache> function memcache_get_extended_stats ] {
- Parameters [4] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <optional> string $type ]
Parameter #2 [ <optional> int $slabid ]
Parameter #3 [ <optional> int $limit ]
}
}
Function [ <internal:memcache> function memcache_set_compress_threshold ] {
- Parameters [3] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> int $threshold ]
Parameter #2 [ <optional> float $min_savings ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_increment ] {
- Parameters [5] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> $key ]
Parameter #2 [ <optional> int $value ]
Parameter #3 [ <optional> int $defval ]
Parameter #4 [ <optional> int $exptime ]
}
}
Function [ <internal:memcache> function memcache_decrement ] {
- Parameters [5] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> $key ]
Parameter #2 [ <optional> int $value ]
Parameter #3 [ <optional> int $defval ]
Parameter #4 [ <optional> int $exptime ]
}
}
Function [ <internal:memcache> function memcache_close ] {
- Parameters [1] {
Parameter #0 [ <required> MemcachePool $memcache ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_flush ] {
- Parameters [2] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <optional> int $delay ]
}
- Return [ bool ]
}
Function [ <internal:memcache> function memcache_set_sasl_auth_data ] {
- Parameters [3] {
Parameter #0 [ <required> MemcachePool $memcache ]
Parameter #1 [ <required> string $username ]
Parameter #2 [ <required> string $password ]
}
- Return [ bool ]
}

View File

@@ -1,7 +1,10 @@
--TEST--
memcache_flush()
--SKIPIF--
<?php include 'connect.inc'; ?>
<?php
if (PHP_VERSION_ID < 80000)
die('skip php 8+ only');
include 'connect.inc'; ?>
--FILE--
<?php

54
tests/100bphpt Normal file
View File

@@ -0,0 +1,54 @@
--TEST--
memcache_flush()
--SKIPIF--
<?php
if (PHP_VERSION_ID >= 80000)
die('skip php prior to 8 only');
include 'connect.inc'; ?>
--FILE--
<?php
// This test must be run last or some concurrency problems will occur
// since the "flush_all" seems to be done async and therefore will
// affect subsequent calls to set() done with a second or so.
include 'connect.inc';
$result = @memcache_flush($memcache);
var_dump($result);
memcache_add_server($memcache, $nonExistingHost, $nonExistingPort);
$result = @memcache_flush($memcache);
var_dump($result);
$memcache2 = new Memcache();
$memcache2->addServer($nonExistingHost, $nonExistingPort);
$result = @memcache_flush($memcache2);
var_dump($result);
memcache_close($memcache);
var_dump(memcache_flush($memcache));
try {
var_dump(memcache_flush(new stdClass));
} catch (TypeError $e) {
echo "{$e->getMessage()}\n";
}
try {
var_dump(memcache_flush(''));
} catch (TypeError $e) {
echo "{$e->getMessage()}\n";
}
echo "Done\n";
?>
--EXPECTF--
bool(true)
bool(false)
bool(false)
bool(true)
Argument 1 passed to memcache_flush() must be an instance of MemcachePool, instance of stdClass given
Argument 1 passed to memcache_flush() must be an instance of MemcachePool, string given
Done

View File

@@ -20,7 +20,7 @@ $port2 = 11212;
//ini_set('memcache.hash_strategy', 'standard');
//ini_set('memcache.hash_function', 'fnv');
//ini_set('memcache.protocol', 'binary');
ini_set('memcache.protocol', getenv('MEMCACHE_PROTOCOL') ?: 'ascii');
if (ini_get('memcache.protocol') == 'binary') {
$udpPort = 0;

26
tests/githubbug53.phpt Normal file
View File

@@ -0,0 +1,26 @@
--TEST--
Module shouldn't crash on failed serialization
--SKIPIF--
<?php include 'connect.inc'; ?>
--FILE--
<?php
include 'connect.inc';
class foo {
function __sleep() {
throw new \Exception("fail");
}
}
$oFoo = new foo();
$memcache->set('foobar', $oFoo);
--EXPECTF--
Warning: MemcachePool::set(): Failed to serialize value in %s on line %d
Fatal error: Uncaught Exception: fail in %s:%d
Stack trace:
#0 [internal function]: foo->__sleep()
#1 %s(%d): MemcachePool->set('foobar', Object(foo))
#2 {main}
thrown in %s on line %d

View File

@@ -10,6 +10,10 @@ include 'connect.inc';
$m = new Memcache();
$m->connect('localhost', 11211);
$m->delete('a');
$m->delete('b');
$m->delete('c');
var_dump($m->increment('a', 42));
var_dump($m->get('a'));
@@ -21,14 +25,11 @@ $m->set('c', 1);
var_dump($m->increment('c', 42));
var_dump($m->get('c'));
$m->flush();
?>
--EXPECTF--
bool(false)
bool(false)
Notice: MemcachePool::increment(): Server localhost (tcp 11211, udp 0) failed with: CLIENT_ERROR cannot increment or decrement non-numeric value
(6) in %s/pecl17518.php on line 12
Notice: MemcachePool::increment(): Server localhost (tcp 11211, udp 0) failed with: %s (%d) in %s
bool(false)
string(3) "bar"
int(43)

21
tests/pecl77900.phpt Normal file
View File

@@ -0,0 +1,21 @@
--TEST--
PECL Bug #77900 (Memcache session handling, zend_mm_heap corrupted)
--SKIPIF--
<?php include 'connect.inc'; ?>
--FILE--
<?php
include 'connect.inc';
ini_set('session.save_handler', 'memcache');
ini_set('session.save_path', "tcp://$host:$port");
session_start();
$_SESSION['test']=true;
session_write_close();
session_start();
var_dump($_SESSION);
session_write_close();
--EXPECT--
array(1) {
["test"]=>
bool(true)
}