Skip to content

Cache::ALL alwayes deletes whole cache, even when called over namespace #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dg opened this issue Mar 18, 2016 · 1 comment
Closed

Comments

@dg
Copy link
Member

dg commented Mar 18, 2016

Moved from nette/nette#592

@forstjiri
Copy link

For my installation, i added Cache::NAMESPACE and this code to Filestorage clean method.

$namespaces = $conditions[Cache::NAMESPACE] ?? false;
.
.
.
else if($namespaces) {
            if (!is_array($namespaces)) {
                $namespaces = [$namespaces];
            }

            foreach ($namespaces as $namespace) {
                $dir = $this->dir . "/_$namespace";
                $items = Nette\Utils\Finder::findFiles('')->from($dir);
                foreach ($items as $item) {
                    $this->delete($item);
                }
                @rmdir($dir);
		    }
		}
.
.
.

It seems to work fine.

Also added this to SqlLiteStorage, but havent tested it:

.
.
.
else if(!empty($conditions[Cache::NAMESPACE])) {
            if (is_array($conditions[Cache::NAMESPACE])) {
                $namespaces = $conditions[Cache::NAMESPACE];
            } else {
                $namespaces = [$conditions[Cache::NAMESPACE]];
            }

            foreach ($namespaces as $namespace) {
                $this->pdo->prepare("DELETE FROM cache WHERE key LIKE %/_$namespace/%")->execute();
            }

		}
.
.
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants