/** * Deletes all keys from associated tags and all priorities * * @todo optimize * @param string $keys */ private function cleanEntry($keys) { foreach (is_array($keys) ? $keys : [$keys] as $key) { $entries = $this->entryTags($key); $this->client->multi(); foreach ($entries as $tag) { $this->client->sRem($this->formatKey($tag, self::KEYS), $key); } // drop tags of entry and priority, in case there are some $this->client->del($this->formatKey($key, self::TAGS), $this->formatKey($key, self::PRIORITY)); $this->client->zRem($this->formatKey(self::PRIORITY), $key); $this->client->exec(); } }
/** * @param string $key */ public function release($key) { if (!isset($this->keys[$key])) { return FALSE; } if ($this->keys[$key] <= time()) { unset($this->keys[$key]); return FALSE; } $this->client->del($this->formatLock($key)); unset($this->keys[$key]); return TRUE; }