lithium\storage\cache\adapter\Memcache::write()
Implements
lithium\storage\cache\Adapter::write()
Write values to the cache. All items to be cached will receive an
expiration time of $expiry
.
Expiration is always based off the current unix time in order to gurantee we never exceed the TTL limit of 30 days when specifying the TTL directly.
Parameters
-
array
$keys
Key/value pairs with keys to uniquely identify the to-be-cached item.
-
string|integer
$expiry
A
strtotime()
compatible cache time or TTL in seconds. To persist an item use\lithium\storage\Cache::PERSIST
.
Returns
booleantrue
on successful write, false
otherwise.
Source
public function write(array $keys, $expiry = null) {
$expiry = $expiry || $expiry === Cache::PERSIST ? $expiry : $this->_config['expiry'];
if (!$expiry || $expiry === Cache::PERSIST) {
$expires = 0;
} elseif (is_int($expiry)) {
$expires = $expiry + time();
} else {
$expires = strtotime($expiry);
}
if (count($keys) > 1) {
return $this->connection->setMulti($keys, $expires);
}
return $this->connection->set(key($keys), current($keys), $expires);
}