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

Memcached::setMulti

PHP function Edit on GitHub ✎

(PECL memcached >= 0.1.0)

Store multiple items

Description

Memcached::setMulti(array $items, int $expiration = 0): bool

Memcached::setMulti() is similar to Memcached::set, but instead of a single key/value item, it works on multiple items specified in items. The expiration time applies to all the items at once.

Parameters

items

Items

expiration

Expiration

Return Values

Success Getresultcode

Examples

Memcached::setMulti() example

php
<?php
$m = new Memcached();
$m->addServer('localhost', 11211);

$items = array(
    'key1' => 'value1',
    'key2' => 'value2',
    'key3' => 'value3'
);
$m->setMulti($items, time() + 300);
?>

See Also

  • Memcached::setMultiByKey
  • Memcached::set

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