mirror of
https://github.com/php-win-ext/php-memcached.git
synced 2026-03-24 00:52:18 +01:00
Add isPersistent method.
This commit is contained in:
@@ -147,6 +147,8 @@ class Memcached {
|
||||
|
||||
public function getResultMessage( ) {}
|
||||
|
||||
public function isPersistent( ) {}
|
||||
|
||||
}
|
||||
|
||||
class MemcachedException extends Exception {
|
||||
|
||||
@@ -2001,6 +2001,20 @@ static PHP_METHOD(Memcached, getResultMessage)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ Memcached::isPersistent()
|
||||
Returns the true if instance uses a persistent connection */
|
||||
static PHP_METHOD(Memcached, isPersistent)
|
||||
{
|
||||
MEMC_METHOD_INIT_VARS;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
MEMC_METHOD_FETCH_OBJECT;
|
||||
|
||||
RETURN_BOOL(i_obj->is_persistent);
|
||||
}
|
||||
|
||||
/****************************************
|
||||
Internal support code
|
||||
@@ -2930,6 +2944,9 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_getVersion, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_isPersistent, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
/* }}} */
|
||||
|
||||
/* {{{ memcached_class_methods */
|
||||
@@ -2982,7 +2999,9 @@ static zend_function_entry memcached_class_methods[] = {
|
||||
|
||||
MEMC_ME(getOption, arginfo_getOption)
|
||||
MEMC_ME(setOption, arginfo_setOption)
|
||||
MEMC_ME(setOptions, arginfo_setOptions)
|
||||
MEMC_ME(setOptions, arginfo_setOptions)
|
||||
|
||||
MEMC_ME(isPersistent, arginfo_isPersistent)
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
#undef MEMC_ME
|
||||
|
||||
37
tests/check_if_persistent.phpt
Normal file
37
tests/check_if_persistent.phpt
Normal file
@@ -0,0 +1,37 @@
|
||||
--TEST--
|
||||
Check if persistent object is persistent
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("memcached")) print "skip";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$m1 = new Memcached('id1');
|
||||
$m1->setOption(Memcached::OPT_PREFIX_KEY, "foo_");
|
||||
|
||||
var_dump($m1->isPersistent());
|
||||
|
||||
$m1 = new Memcached('id1');
|
||||
var_dump($m1->isPersistent());
|
||||
|
||||
$m2 = new Memcached('id1');
|
||||
var_dump($m2->isPersistent());
|
||||
// this change affects $m1
|
||||
$m2->setOption(Memcached::OPT_PREFIX_KEY, "bar_");
|
||||
|
||||
$m3 = new Memcached('id2');
|
||||
var_dump($m3->isPersistent());
|
||||
|
||||
$m3 = new Memcached();
|
||||
var_dump($m3->isPersistent());
|
||||
|
||||
// objects have the same resource, but they are not the same object.
|
||||
var_dump($m1 === $m2);
|
||||
var_dump($m1->getOption(Memcached::OPT_PREFIX_KEY));
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(4) "bar_"
|
||||
Reference in New Issue
Block a user