CodeIgniter Forums
Delete one cache file with cache driver - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Delete one cache file with cache driver (/showthread.php?tid=68411)



Delete one cache file with cache driver - krystian2160 - 07-07-2017

I can delete one cache file by

PHP Code:
$this->output->delete_cache('dfgdfg'); 

But why this two doesn't work?


PHP Code:
$this->load->driver('cache');
 if ( 
$this->cache->delete('dfgdfg') ) echo 1

and

PHP Code:
$this->load->driver('cache');
 if ( 
$this->cache->file->delete('dfgdfg') ) echo 1


first one (cache->delete) returns nothing in echo
Second one (cache-file->delete) returns 1 - success? but nothing gets delete, and refreshing page and success success success... but nothing deletes.

$this->cache->file->clean(); works for me
But $this->cache->file->delete doens't, $this->cache->delete doesn't work too.

Why?


RE: Delete one cache file with cache driver - Martin7483 - 07-07-2017

Without seeing your cache configuration we can't tell you anything


RE: Delete one cache file with cache driver - krystian2160 - 07-07-2017

I do not have any cache configuration. Just `$this->output->cache(3600);` in controller's constructor


RE: Delete one cache file with cache driver - Martin7483 - 07-07-2017

And there is your answer.

PHP Code:
$this->output->cache($n); 
is for web page caching

See the docs
https://codeigniter.com/user_guide/general/caching.html

You are referring to a cache driver which is not used when calling
$this->output->cache($n);

So calling
PHP Code:
$this->cache->delete 
won't have any effect on a cached web page

A cache driver is used for caching partial views, or other types of data.
But when using web page caching, all other view caching is obsolete as CodeIgniter will exit execution when a valid cache output is found.


RE: Delete one cache file with cache driver - krystian2160 - 07-07-2017

Thank you Smile Now I understand


RE: Delete one cache file with cache driver - Martin7483 - 07-07-2017

(07-07-2017, 05:15 AM)krystian2160 Wrote: Thank you Smile Now I understand

You are welcome Smile