Memcached::setOption

(PECL memcached >= 0.1.0)

Memcached::setOptionConfigure une option Memcached

Description

public Memcached::setOption(int $option, mixed $value): bool

Memcached::setOption() configure une valeur de l'option Memcached option avec la valeur value. Certaines options correspondent à celles définies dans libmemcached, et d'autres sont spécifiques à l'extension. Voyez les constantes Memcached pour plus d'informations.

Les options listées ci-dessous requièrent des valeurs fournies par les constantes :

  • Memcached::OPT_HASH requiert une constante Memcached::HASH_*.

  • Memcached::OPT_DISTRIBUTION requiert une constante Memcached::DISTRIBUTION_*.

Valeurs de retour

Cette fonction retourne true en cas de succès ou false si une erreur survient.

Exemples

Exemple #1 Configuration d'une option Memcached

<?php
$m 
= new Memcached();
var_dump($m->getOption(Memcached::OPT_HASH) == Memcached::HASH_DEFAULT);
$m->setOption(Memcached::OPT_HASHMemcached::HASH_MURMUR);
$m->setOption(Memcached::OPT_PREFIX_KEY"widgets");
echo 
"Le préfixe de la clé est maintenant : "$m->getOption(Memcached::OPT_PREFIX_KEY), "\n";
?>

L'exemple ci-dessus va afficher :

bool(true)
Le préfixe de la clé est maintenant : widgets

Voir aussi

add a note add a note

User Contributed Notes 1 note

up
0
Harry Fuecks
13 years ago
Be warned that setting the option Memcached::OPT_DISTRIBUTION to Memcached::DISTRIBUTION_CONSISTENT can carry a significant performance hit so is best used with persistent connections. More details at http://github.com/andreiz/php-memcached/issues#issue/14
To Top