public function save($key, $value, $ttl = 2592000, $tags = NULL)
{
if (empty($key) || $value === NULL) {
$this->ReportError('empty keys and null values are not allowed', __LINE__);
return false;
}
$key = (string) $key;
$auto_unlocker = NULL;
if (!$this->sem->get_access_write($auto_unlocker)) {
return false;
}
$this->del_old();
$this->readmemory();
$this->mem[self::map_keys][$key] = $value;
$ttl = intval($ttl);
if ($ttl > 0) {
$this->mem[self::map_key_ttl][$key] = time() + $ttl;
}
if (!empty($tags)) {
if (!is_array($tags)) {
$tags = array($tags);
}
foreach ($tags as $tag) {
if (empty($this->mem[self::map_key_tags][$tag]) || !in_array($key, $this->mem[self::map_key_tags][$tag])) {
$this->mem[self::map_key_tags][$tag][] = $key;
}
}
}
return $this->refresh();
}