/** * Deletes the cache record(s). * * @param string $key Cache key name or pattern * @param boolean $prefix_mode Enable it to clear all keys starting * with prefix specified in $key */ private function remove_record($key = null, $prefix_mode = false) { if (!$this->db) { return; } if ($this->type != 'db') { $this->load_index(); // Remove all keys if ($key === null) { foreach ($this->index as $key) { $this->delete_record($this->ckey($key)); } $this->index = array(); } else { if ($prefix_mode) { foreach ($this->index as $idx => $k) { if (strpos($k, $key) === 0) { $this->delete_record($this->ckey($k)); unset($this->index[$idx]); } } } else { $this->delete_record($this->ckey($key)); if (($idx = array_search($key, $this->index)) !== false) { unset($this->index[$idx]); } } } $this->index_changed = true; return; } // Remove all keys (in specified cache) if ($key === null) { $where = " WHERE `cache_key` LIKE " . $this->db->quote($this->prefix . '.%'); } else { if ($prefix_mode) { $where = " WHERE `cache_key` LIKE " . $this->db->quote($this->prefix . '.' . $key . '%'); } else { $where = " WHERE `cache_key` = " . $this->db->quote($this->prefix . '.' . $key); } } $this->db->query("DELETE FROM " . $this->table . $where); }
/** * Deletes the cache record(s). * * @param string $key Cache key name or pattern * @param boolean $prefix_mode Enable it to clear all keys starting * with prefix specified in $key */ private function remove_record($key = null, $prefix_mode = false) { if (!$this->db) { return; } if ($this->type != 'db') { $this->load_index(); // Remove all keys if ($key === null) { foreach ($this->index as $key) { $this->delete_record($key, false); } $this->index = array(); } else { if ($prefix_mode) { foreach ($this->index as $k) { if (strpos($k, $key) === 0) { $this->delete_record($k); } } } else { $this->delete_record($key); } } return; } // Remove all keys (in specified cache) if ($key === null) { $where = " AND cache_key LIKE " . $this->db->quote($this->prefix . '.%'); } else { if ($prefix_mode) { $where = " AND cache_key LIKE " . $this->db->quote($this->prefix . '.' . $key . '%'); } else { $where = " AND cache_key = " . $this->db->quote($this->prefix . '.' . $key); } } $this->db->query("DELETE FROM " . $this->table . " WHERE user_id = ?" . $where, $this->userid); }