Skip to content
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

Filedriver purge didn't work in docker #386

Closed
konorlevich opened this issue Apr 11, 2019 · 2 comments
Closed

Filedriver purge didn't work in docker #386

konorlevich opened this issue Apr 11, 2019 · 2 comments

Comments

@konorlevich
Copy link

###PHP version

PHP 7.3.3-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Mar 7 2019 20:31:49) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.3-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.7.0, Copyright (c) 2002-2019, by Derick Rethans

tedivm/stash version: v0.14.2

Steps to reproduce

$result = [
    'hittedAfterPurge' => 0,
    'hitted' => 0,
    'missed' => 0,
];
$i = 1000;
while ($i-- > 0) {
    $expiresIn = mt_rand(40, 1000);
    $cacheKey = hash('sha256', 'some string' . $expiresIn);
    $data = ['key1' => 1, 'key2' => 2];
    $pool = new Stash\Pool(new \Stash\Driver\FileSystem);
    $pool->purge();
    if ($pool->hasItem($cacheKey)) {
        $result['hittedAfterPurge']++;
    }
    $cacheItem = $pool->getItem($cacheKey)
        ->set($data)
        ->expiresAt(new \DateTime('@' . (time() + $expiresIn)));

    $saved = $pool->save($cacheItem);
    $hasItem = $pool->hasItem($cacheKey);
    if ($hasItem) {
        $result['hitted']++;
        continue;
    }
    $result['missed']++;
}
foreach ([
             'hittedAfterPurge' => $result['hittedAfterPurge'],
             'hitted' => $result['hitted'],
             'missed' => $result['missed'],
         ] as $key => $value) {
    echo $key, ' : ', var_export($value), PHP_EOL;
}

Result

hittedAfterPurge : 351
hitted : 991
missed : 9

@tedivm
Copy link
Member

tedivm commented Apr 17, 2019

Purge doesn't erase items from the cache, it simply cleans up items from the filesystem that have already expired (for some backends this happens automatically and purge doesn't do anything at all).

If you want to remove everything from the cache you need to run clear instead of purge.

@tedivm tedivm closed this as completed Apr 17, 2019
@konorlevich
Copy link
Author

konorlevich commented Apr 26, 2019

mom said i'm special (с)

Thanks

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