public function MemcacheDriver::add in Memcache API and Integration 8.2
Add an item to Memcache if it doesn't exist already.
Parameters
string $key: The key to add.
mixed $value: The value to add.
int $expire: The expiration time in seconds.
Return value
bool TRUE on success or FALSE on failure.
Overrides DrupalMemcacheInterface::add
File
- src/
Driver/ MemcacheDriver.php, line 29
Class
- MemcacheDriver
- Class MemcacheDriver.
Namespace
Drupal\memcache\DriverCode
public function add($key, $value, $expire = 0) {
$collect_stats = $this
->statsInit();
$full_key = $this
->key($key);
$result = $this->memcache
->add($full_key, $value, FALSE, $expire);
if ($collect_stats) {
$this
->statsWrite('add', 'cache', [
$full_key => (int) $result,
]);
}
return $result;
}