protected setValue ( string $key, string $value, integer $expire ) : boolean | ||
$key | string | the key identifying the value to be cached |
$value | string | the value to be cached |
$expire | integer | the number of seconds in which the cached value will expire. 0 means never expire. |
return | boolean | true if the value is successfully stored into cache, false otherwise |
protected function setValue($key, $value, $expire)
{
$result = $this->db->getCollection($this->cacheCollection)->update(['id' => $key], ['expire' => $expire > 0 ? $expire + time() : 0, 'data' => $value]);
if ($result) {
$this->gc();
return true;
} else {
return $this->addValue($key, $value, $expire);
}
}