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

Memcached::add

PHP function Edit on GitHub ✎

(PECL memcached >= 0.1.0)

Add an item under a new key

Description

Memcached::add(string $key, mixed $value, int $expiration = 0): bool

Memcached::add() is similar to Memcached::set, but the operation fails if the key already exists on the server.

Parameters

key

Key

value

Value

expiration

Expiration

Return Values

Success The Memcached::getResultCode will return Memcached::RES_NOTSTORED if the key already exists.

See Also

  • Memcached::addByKey
  • Memcached::set
  • Memcached::replace

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