Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

deleted cache still there?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Jammyman
Smarty Rookie


Joined: 07 Aug 2003
Posts: 7

PostPosted: Tue Oct 07, 2003 5:36 pm    Post subject: deleted cache still there? Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Oct 07, 2003 6:23 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Jammyman
Smarty Rookie


Joined: 07 Aug 2003
Posts: 7

PostPosted: Tue Oct 07, 2003 6:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
Jammyman
Smarty Rookie


Joined: 07 Aug 2003
Posts: 7

PostPosted: Tue Oct 07, 2003 6:53 pm    Post subject: Reply with quote

Or i did not understand, i cant get the page go away Sad

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
View user's profile Send private message
Jammyman
Smarty Rookie


Joined: 07 Aug 2003
Posts: 7

PostPosted: Tue Oct 07, 2003 7:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
jn
Smarty Rookie


Joined: 29 Sep 2003
Posts: 7
Location: Germay

PostPosted: Thu Oct 09, 2003 11:27 am    Post subject: Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Oct 09, 2003 3:19 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
jn
Smarty Rookie


Joined: 29 Sep 2003
Posts: 7
Location: Germay

PostPosted: Thu Oct 09, 2003 6:45 pm    Post subject: Reply with quote

So it is not possible to clear all caches of a single template (without knowing their cache IDs)?

Jörg
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Oct 09, 2003 8:40 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
jn
Smarty Rookie


Joined: 29 Sep 2003
Posts: 7
Location: Germay

PostPosted: Fri Oct 10, 2003 6:40 am    Post subject: Reply with quote

quite intuitive Rolling Eyes

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Fri Oct 10, 2003 8:00 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP