php8.5
Home/ Manual/ memcached / memcached/ Memcached::setOptions

Memcached::setOptions

PHP function Edit on GitHub ✎

(PECL memcached >= 2.0.0)

Set Memcached options

Description

Memcached::setOptions(array $options): bool

Memcached::setOptions() is a variation of the Memcached::setOption that takes an array of options to be set.

Parameters

options

An associative array of options where the key is the option to set and the value is the new value for the option.

Return Values

Success

Examples

Setting Memcached options

php
<?php
$m = new Memcached();
var_dump($m->getOption(Memcached::OPT_HASH) == Memcached::HASH_DEFAULT);

$m->setOptions(array(Memcached::OPT_HASH => Memcached::HASH_MURMUR, Memcached::OPT_PREFIX_KEY => "widgets"));

var_dump($m->getOption(Memcached::OPT_HASH) == Memcached::HASH_DEFAULT);
echo "Prefix key is now: ", $m->getOption(Memcached::OPT_PREFIX_KEY), "\n";
?>

The above example will output:

output
bool(true)
bool(false)
Prefix key is now: widgets

See Also

Source: reference/memcached/memcached/setoptions.xml · from the official PHP manual (php/doc-en)