|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Dummkopf Smarty Rookie
Joined: 19 Apr 2003 Posts: 23
|
Posted: Tue May 11, 2004 5:26 pm Post subject: Clearing cache-file without compile_id - possible? |
|
|
Hi all,
I have several template-folders, one for each skin.
Because it may happen, that a template-file is called the same as another one in a different skin, I call them with compile_id = skin_name.
In the game-environment there are three skins available.
After certain gamer's-actions I need to delete the cache for the template ressourcen.tpl for a certain player. (cache_id = "user|user_id|language")
I want to clear all caches from templates, which are called 'ressourcen.tpl' and are in cache-group "user|145". (clear-cache(ressourcen.tpl, user|145)
The cache for ressourcen.tpl isn't deleted, though, because I don't give Smarty any compile_id.
Is there any way to delete template-caches with EVERY existing compile_id just with template-name and cache-group? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue May 11, 2004 6:35 pm Post subject: |
|
|
Make sure compile_id is null when you clear the cache. (eg. don't set $smarty->compile_id, or set it to null first) |
|
Back to top |
|
Dummkopf Smarty Rookie
Joined: 19 Apr 2003 Posts: 23
|
Posted: Wed May 12, 2004 5:00 pm Post subject: |
|
|
If I set it to NULL the files are not cleared, because I fetched them with a certain compile_id != NULL.
is_cached('ressourcen.tpl', 'user|145|de', 'skin_1') => TRUE
The language of player 145 and his skin are unknown.
Nevertheless I want to clear ALL cache files for the template ressourcen.tpl, which are in cache-group "user|145".
If there is no possibility to do this, I will have to walk through every possible combination of languages and skins. (Two languages and three skins would mean: 6 function calls every time I want to clear a cache-file of another player. ['user|145|de', 'skin_1'; 'user|145|de', 'skin_2'; etc.]) |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed May 12, 2004 5:09 pm Post subject: |
|
|
rule of thumb: if you pass a resource-name to clear_cache() there is never more than one file deleted. (read: you are right, you'd have to call clear_cache() for all possible compile_ids).
use null as resource-name to clear the whole cachegroup for all compile_ids. if you really only want to delete "ressourcen.tpl", make "ressourcen" part of the cache_id. but often it's enough to clear cached content by cache_id and not by template. |
|
Back to top |
|
Dummkopf Smarty Rookie
Joined: 19 Apr 2003 Posts: 23
|
Posted: Wed May 12, 2004 5:17 pm Post subject: |
|
|
Is there at least a possibility to delete whole cache-groups?
clear_cache('ressourcen.tpl', 'user|145', 'skin_1') doesn't clear any file but should clear the following:
('r.tpl', 'user|145|de', 'skin_1')
('r.tpl', 'user|145|en', 'skin_1')
('r.tpl', 'user|145|fr', 'skin_1')
Referring to your tip:
ressourcen.tpl would be fetched via ('ressourcen.tpl', 'user|145|ressourcen|de', 'skin_1') for example and cleared via clear_cache(NULL, 'user|145|ressourcen', NULL), right?
I will just check whether it really clears the whole cache-group for EVERY compile_id. If so, I will change it accordingly. Thanks for the idea! |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed May 12, 2004 6:38 pm Post subject: |
|
|
The compile id is essentially treated as the last cache group.
You can think of it like this:
$smarty->clear_cache('index.tpl','a|b|c','foobar');
If you think of it like a file system, clear_cache will try to clear the file:
/a/b/c/foobar/index.tpl
Now we leave the template null:
$smarty->clear_cache(null,'a|b|c','foobar');
and this clears everything under:
/a/b/c/foobar/*
Now we leave the compile_id null but supply the template:
$smarty->clear_cache('index.tpl','a|b|c',null);
and this clears the particular cache file:
/a/b/c/index.tpl
which of course won't work. What you are trying to accomplish is:
/a/b/c/*/index.tpl
which the cache system has no concept of, it only works left-to-right.
So messju is correct, you need to put your "grouped" templates into their own cache group, so something like this:
$smarty->clear_cache(null,'a|b|c|mygroup',null);
will clear out:
/a/b/c/mygroup/* |
|
Back to top |
|
Dummkopf Smarty Rookie
Joined: 19 Apr 2003 Posts: 23
|
Posted: Wed May 12, 2004 6:55 pm Post subject: |
|
|
It's working fine now. Thank you very much for your help!
The fetching has now got this format:
Template: $template
CacheID: [user | $userID |] $template | [$specialCacheID |] $language
CompileID: $skin
To clear a certain template-cache of a certain player, I can use:
(clear_cache)
Template: NULL
CacheID: user | $userID | $template [| $specialCacheID]
CompileID: NULL
which clears all template files $template in cache-group user|userID for every skin and every language!
Smarty is so great! |
|
Back to top |
|
|
|
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
|
|