Welcome Guest, Not a member yet? Register   Sign In
Database Query Caching - Cache won't delete
#1

[eluser]Twisted1919[/eluser]
In database.php i have
$db['default']['cachedir'] = "./system/db_cache";
The folder has chmod 0777 ,
The cache content is creating when i want to do it , but when doing ,
$this->db->cache_delete('home','hello-word-method');
the content will not be deleted .
Why is that ?
It has something to do with the fact that i'm using the uri routing , and the _remap function ? (even if i don't think so)

If a method is called do_domething , and i remap it to do-domething , then when i delete my cache must do $this->db->cache_delete('home','do_something'); ?

Thx .
#2

[eluser]wabu[/eluser]
Hello, do the parameters you're passing to cache_delete() match the directory you're seeing created? And the directory's not empty after calling the delete method?

From your post it sounds like you have some other variables it might be helpful to eliminate for testing purposes. If it were me I'd break it down to the smallest possible test case and build it back up once that's working.
#3

[eluser]Twisted1919[/eluser]
The controller is called view , the method is re-routed to show-posts, originally is called show_posts ,
Now, in my cache dir ai have view+show-posts .
When i try to delete i do : $this->db->cache_delete('view','show-posts');
The folder is still there , also it's content is there , so this is not working .
If the method can create the right folders under my cache dir , that means the folder is writeable right ?
So , why is this not working as it should be ?
#4

[eluser]wabu[/eluser]
It looks like CI_DB_Cache's delete function is pretty literal in deleting just what you specify in the parameters, so cache_delete(‘view’,‘show-posts’) should delete 'view+show-posts.'

You might try simply debugging DB_cache.php (delete function) just to see what's being passed to delete_files(). If that looks okay then you could do the same with delete_files (in file_helper.php).
#5

[eluser]Twisted1919[/eluser]
Thanks wabu , yesterday i was too tired , but today i took a closer approach and i solved my problem .
I took a look in log file and saw :
ERROR - 2009-10-06 04:14:07 --&gt; Severity: Warning --&gt; opendir(./system/db_cacheview+show-posts) [<a href='function.opendir'>function.opendir</a>]: failed to open dir: No such file or directory /var/www/vhosts/domain.com/httpdocs/myapp/system/helpers/file_helper.php 126

So, the problem was that $db['default']['cachedir'] = "./system/db_cache"; MUST have a trailing slash :
$db['default']['cachedir'] = "./system/db_cache/";
This was the reason , the system tryed to open ./system/db_cacheview+show-posts instead of ./system/db_cache/view+show-posts .
And as you can see the delete_files function is used when deleting cached files in database class .
Anyway, thanks for the heads up on this one Smile
#6

[eluser]wabu[/eluser]
That's weird because I think I remember seeing some code in there that added a trailing slash if necessary.

FWIW I wasn't successful using relative paths--I needed to specify full paths.
#7

[eluser]niki_mihaylov[/eluser]
Hello,
if you see in the DB_cache.php file in the delete function you will notice something like:

Code:
$dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/';

in here you pass the segments as strings and before that you have your cachedir which is missing the /

So the solution is to add a / at the end of your db cache config folder:

Code:
$db['default']['cachedir'] = 'application/cache/';




Theme © iAndrew 2016 - Forum software by © MyBB