/**
  * @param string $key
  * @param array|string $tags
  * @return bool
  */
 public function set_tags($key, $tags)
 {
     if (!is_array($tags)) {
         if (is_scalar($tags)) {
             $tags = array($tags);
         } else {
             $tags = array();
         }
     }
     if (!empty($tags)) {
         $key = (string) $key;
         $tags_table = $this->memcache->get($this->tags_table_name);
         if (empty($tags_table)) {
             $tags_table = array();
         }
         if (!array_key_exists($key, $tags_table) || $tags != $tags_table[$key]) {
             $tags_table[$key] = $tags;
             return $this->memcache->set($this->tags_table_name, $tags_table, null, time() + self::max_ttl);
         } else {
             return true;
         }
     }
     return false;
 }
Example #2
0
 protected function getKeysOfTag($tag)
 {
     return $this->memcache->get($this->tag_prefix . $tag);
 }