Files
php-memcached/tests/setoptions.phpt
Robert e39a2e62f4 Add option to locally enforce payload size limit (#515)
Add a configuration option to enforce an item size limit on the client side. This avoids sending large items
over the wire and getting rejected by the server which can cause delays. The default is 0 for no limit.
The same error code RES_E2BIG is used for the client side limit as for the server side limit.
2023-04-27 08:48:49 -07:00

49 lines
1.2 KiB
PHP

--TEST--
Set options using setOptions
--SKIPIF--
<?php include "skipif.inc";?>
--FILE--
<?php
$m = new Memcached();
/* existing options */
var_dump($m->setOptions(array(
Memcached::OPT_PREFIX_KEY => 'a_prefix',
Memcached::OPT_SERIALIZER => Memcached::SERIALIZER_PHP,
Memcached::OPT_COMPRESSION => 0,
Memcached::OPT_LIBKETAMA_COMPATIBLE => 1,
Memcached::OPT_CONNECT_TIMEOUT => 5000,
Memcached::OPT_ITEM_SIZE_LIMIT => 1000000,
)));
var_dump($m->getOption(Memcached::OPT_PREFIX_KEY) == 'a_prefix');
var_dump($m->getOption(Memcached::OPT_SERIALIZER) == Memcached::SERIALIZER_PHP);
var_dump($m->getOption(Memcached::OPT_COMPRESSION) == 0);
var_dump($m->getOption(Memcached::OPT_LIBKETAMA_COMPATIBLE) == 1);
var_dump($m->getOption(Memcached::OPT_ITEM_SIZE_LIMIT) == 1000000);
echo "test invalid options\n";
var_dump($m->setOptions(array(
"asdf" => 123
)));
var_dump($m->setOptions(array(
-1 => 123
)));
--EXPECTF--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
test invalid options
Warning: Memcached::setOptions(): invalid configuration option in %s on line %d
bool(false)
Warning: Memcached::setOptions(): error setting memcached option: %s in %s on line %d
bool(false)