|
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 |
datamile Smarty Rookie
Joined: 17 May 2003 Posts: 13
|
Posted: Fri Oct 17, 2003 9:28 pm Post subject: is_cache and clear_cache |
|
|
Might be a bug or misuse of a feature.
Ok I've got caching on for all pages , and pages have sub-templates , and insert templates with their own cache.
A page has its self , a primary block from which its gets title etc , and several secondary blocks. Primary and secondary can swap around depending on the page.
If a block is first cached as a secondary block, then is needed as a primary block , and the primary page is not cached, then I need to reload the primary to get the data to transfer to the primary page.
So I used the full logic
before generating the primary page and primary block
if !is_cache(primary_page) and is_cache(primary_block)
clear_cache(primary_block)
end
then primary block code says
if !is_cache(primary_block)
get_data etc
end
fetch_template.
The problem is that the first is_cache(primary_block) calls _read_cache_file which puts the template in static var content_cache. After this, deleting the cache file has no effect , as the second is_cache just looks at content_cache and believes the template loaded. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Fri Oct 17, 2003 10:15 pm Post subject: |
|
|
it's a feature. if is_cached() returns true, it saves the cached page as a static variable (as you noticed). this avoids a race-condition that may occur between calling is_cached() and calling display() (believing your page is cached). |
|
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
|