Welcome Guest, Not a member yet? Register   Sign In
Expired cache files are not cleared
#1

(This post was last modified: 04-20-2021, 10:05 AM by AngelRodriguez.)

Hi,

I have a problem, expired cache files are not cleared.

Saving cache like (this for example) version CI 4.1.1

PHP Code:
if (! $foo cache('foo'))
{
    echo 'Saving to the cache!<br />';
    $foo 'foobarbaz!';

    // Save into the cache for 5 minutes
    cache()->save('foo'$foo300);
}

echo 
$foo



Files are supposed to delete themselves, right?

Or do I have to do something manually to delete them?

Thank you

Ángel
Reply
#2

If they do not delete you can do it yourself like so.

PHP Code:
$cache = \Config\Services::cache();

// your cache item id.
$this->cache->delete('cache_item_id');

// clean the cache out.
$this->cache->clean();

// get the cache information.
var_dump($this->cache->cache_info()); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

Get the entire cache and loop one by one, so if it is expired it will return NULL and delete the file.

Code:
$allDataCache = $this->cache->getCacheInfo();
foreach ($allDataCache as $key => $value) {
   $this->cache->get($key);
}
Reply




Theme © iAndrew 2016 - Forum software by © MyBB