/** * Removes items from the cache by conditions & garbage collector. * @param array conditions * @return void */ public function clean(array $conditions) { if (!empty($conditions[Cache::ALL])) { $this->memcache->flush(); } elseif ($this->journal) { foreach ($this->journal->clean($conditions) as $entry) { $this->memcache->delete($entry, 0); } } }
/** * Removes items from the cache by conditions & garbage collector. * @param array conditions * @return void */ public function clean(array $conds) { $all = !empty($conds[Cache::ALL]); $collector = empty($conds); // cleaning using file iterator if ($all || $collector) { $now = time(); foreach (Nette\Utils\Finder::find('*')->from($this->dir)->childFirst() as $entry) { $path = (string) $entry; if ($entry->isDir()) { // collector: remove empty dirs @rmdir($path); // @ - removing dirs is not necessary continue; } if ($all) { $this->delete($path); } else { // collector $meta = $this->readMetaAndLock($path, LOCK_SH); if (!$meta) { continue; } if (!empty($meta[self::META_EXPIRE]) && $meta[self::META_EXPIRE] < $now) { $this->delete($path, $meta[self::HANDLE]); continue; } flock($meta[self::HANDLE], LOCK_UN); fclose($meta[self::HANDLE]); } } if ($this->journal) { $this->journal->clean($conds); } return; } // cleaning using journal if ($this->journal) { foreach ($this->journal->clean($conds) as $file) { $this->delete($file); } } }
/** * Removes items from the cache by conditions & garbage collector. * * @param array $conds * * @return void */ public function clean(array $conds) { // cleaning using file iterator if (!empty($conds[Cache::ALL])) { if ($keys = $this->client->send('keys', [self::NS_NETTE . ':*'])) { $this->client->send('del', $keys); } if ($this->journal) { $this->journal->clean($conds); } return; } // cleaning using journal if ($this->journal) { if ($keys = $this->journal->clean($conds, $this)) { $this->client->send('del', $keys); } } }