View previous topic :: View next topic |
Author |
Message |
Jammyman Smarty Rookie
Joined: 07 Aug 2003 Posts: 7
|
Posted: Tue Oct 07, 2003 5:36 pm Post subject: deleted cache still there? |
|
|
I have strange problem, i use cache in my news page and it looks something like this (like in the manual)
Code: |
if(!$smarty->is_cached(news/news.tpl.html',$documentid)) {
//get the stuff in the db etc...
}
$smarty->display(news/news.tpl.html',$documentid);
|
Ok, then i have admin area where i can delete my news, there i have this script in the same page:
Code: |
$smarty->clear_cache(null,"news");
$smarty->clear_cache("news.tpl.html",$_REQUEST[documentid]);
|
So i try to delete the cached news page, but it's not going anywhere, if i refresh the news page with that documentid, i can still see the document, so what i do wrong here?
Should cache directory look like this? (filelist), there is no files, only empty folders and every folder name is number with or whitout percent sign...
Code: |
drwxr-x--x 3 48 48 4096 Oct 06 12:39 %%-10
drwxr-x--x 3 48 48 4096 Oct 02 07:50 %%-18
drwxr-x--x 3 48 48 4096 Oct 02 07:50 %%-39
drwxr-x--x 3 48 48 4096 Oct 06 13:14 %%-40
drwxr-x--x 3 48 48 4096 Oct 02 12:35 %%-94
drwxr-x--x 3 48 48 4096 Oct 02 07:56 %%100
drwxr-x--x 3 48 48 4096 Oct 02 07:51 %%207
drwxr-x--x 3 48 48 4096 Oct 02 07:55 %%212
drwxr-x--x 3 48 48 4096 Oct 03 07:48 %%238
drwxr-x--x 3 48 48 4096 Oct 03 10:12 %%393
drwxrwxrwx 24 500 500 4096 Oct 07 17:04 .
drwxr-xr-x 28 500 500 4096 Oct 07 16:04 ..
drwxr-x--x 3 48 48 4096 Oct 07 12:26 12
drwxr-x--x 3 48 48 4096 Oct 03 12:27 13
drwxr-x--x 3 48 48 4096 Oct 07 16:58 14
drwxr-x--x 3 48 48 4096 Oct 07 08:02 15
drwxr-x--x 3 48 48 4096 Oct 07 12:38 16
drwxr-x--x 3 48 48 4096 Oct 06 13:13 18
drwxr-x--x 3 48 48 4096 Oct 06 13:14 19
drwxr-x--x 3 48 48 4096 Oct 07 17:04 20
drwxr-x--x 3 48 48 4096 Oct 03 12:11 5
drwxr-x--x 3 48 48 4096 Oct 02 12:26 6
drwxr-x--x 3 48 48 4096 Oct 07 11:45 7
|
Maby it's just something wrong with my code, i have to check things here again...
EDIT:
Ok, now im sure, clear cahce does nothing to me i guess. Document id is 21 and i try to run this script nothing happens, no error messages or anything and cached page is still on my server.
Code: |
$smarty->clear_cache(null,"news.tpl.html");
$smarty->clear_cache(null,"news");
$smarty->clear_cache(news/news.tpl.html',"21");
|
Clear_all below works great, so what am i missing here?
Code: |
smarty->clear_all_cache();
|
|
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Oct 07, 2003 6:23 pm Post subject: |
|
|
you cannot delete a cached file by name *and* id.
you can however
$smarty->clear_cache('news.tpl', null); /* clear all ids (=cachegroups) */
$smarty->clear_cache(null, $id); /* clear all templates of an id (=cachegroup) */ |
|
Back to top |
|
Jammyman Smarty Rookie
Joined: 07 Aug 2003 Posts: 7
|
Posted: Tue Oct 07, 2003 6:28 pm Post subject: |
|
|
messju wrote: | you cannot delete a cached file by name *and* id.
you can however
$smarty->clear_cache('news.tpl', null); /* clear all ids (=cachegroups) */
$smarty->clear_cache(null, $id); /* clear all templates of an id (=cachegroup) */ |
ok, now i get it, thanx!! |
|
Back to top |
|
Jammyman Smarty Rookie
Joined: 07 Aug 2003 Posts: 7
|
Posted: Tue Oct 07, 2003 6:53 pm Post subject: |
|
|
Or i did not understand, i cant get the page go away
Can someone give me working example how to remove all cached pages on my news area, or just one single document on that area.
So far i know that these dont work for me:
$smarty->clear_cache(null,"news.tpl.html");
$smarty->clear_cache(null,"news");
$smarty->clear_cache(news/news.tpl.html',null);
$smarty->clear_cache(news.tpl.html',null);
$smarty->clear_cache(news/news.tpl.html',"21");
I must be really dumb, i did read the manual again etc...
How do i find out cachegroup id on news area on my page? |
|
Back to top |
|
Jammyman Smarty Rookie
Joined: 07 Aug 2003 Posts: 7
|
Posted: Tue Oct 07, 2003 7:13 pm Post subject: |
|
|
ok, problem solved, i needed to give group name, example news like this:
$smarty->clear_cache("news.tpl.html","news|$_REQUEST[documentid]");
Then i can remove all news like this:
$smarty->clear_cache(null,"news"); |
|
Back to top |
|
jn Smarty Rookie
Joined: 29 Sep 2003 Posts: 7 Location: Germay
|
Posted: Thu Oct 09, 2003 11:27 am Post subject: |
|
|
messju wrote: | you cannot delete a cached file by name *and* id.
you can however
$smarty->clear_cache('news.tpl', null); /* clear all ids (=cachegroups) */
$smarty->clear_cache(null, $id); /* clear all templates of an id (=cachegroup) */ |
Unfortunately not. I have set up a complicated compile id which consitsts of 3 parts separated by |; using a cache ID it gives me a directory structure like Code: | cache/cache-ID/Part1/Part2/Part3/%%-45/%%-457870012/myTemplate.php |
The snippet Code: | $foo = new Smarty();
$foo->clear_cache('MyTemplate.tpl', null); | does NOT delete this file (while clear_all_cache is working as documented)
What's wrong here? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Oct 09, 2003 3:19 pm Post subject: |
|
|
jn wrote: | The snippet Code: | $foo = new Smarty();
$foo->clear_cache('MyTemplate.tpl', null); | does NOT delete this file (while clear_all_cache is working as documented)
What's wrong here? |
sorry, my fault. you are right:
$foo->clear_cache('MyTemplate.tpl', null); only removes the cache for the distinct cache_id "null".
if you pass a template-name you have to specify the cache_id and compile_id you want to clear.
if you want to clear potentially more than one template, you have to use cache-groups and pass null as the template-name. |
|
Back to top |
|
jn Smarty Rookie
Joined: 29 Sep 2003 Posts: 7 Location: Germay
|
Posted: Thu Oct 09, 2003 6:45 pm Post subject: |
|
|
So it is not possible to clear all caches of a single template (without knowing their cache IDs)?
Jörg |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Oct 09, 2003 8:40 pm Post subject: |
|
|
AFAIK it's not. as Jammyman pointed out: you have to create a cache group for each template:
$smarty->display('foo.tpl', 'foo|'.$cache_id);
$smarty->display('bar.tpl', 'bar|'.$cache_id);
then you can remove all cached pages of one template by
$smarty->clear_cache(null, 'foo'); // clear out foo.tpl
$smarty->clear_cache(null, 'bar'); // clear out bar.tpl |
|
Back to top |
|
jn Smarty Rookie
Joined: 29 Sep 2003 Posts: 7 Location: Germay
|
Posted: Fri Oct 10, 2003 6:40 am Post subject: |
|
|
quite intuitive
Is this "working as designed" or just an issue? Anyway, that gives me an idea how to achive what I wanted.
Thank you,
Jörg |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Fri Oct 10, 2003 8:00 am Post subject: |
|
|
it seems to be the former ("working as designed"). the manual-page of clear_cache() seems to need an update and state this clear.
greetings
messju |
|
Back to top |
|
|