Include block caches clearing during "clear_cache" hook invocation.

This commit is contained in:
2015-10-12 19:39:41 +02:00
parent 872f2a177d
commit d37f45d958
2 changed files with 32 additions and 0 deletions

View File

@@ -196,6 +196,8 @@ feature -- Hook: cache
h.clear_cache (a_cache_id_list, a_response) h.clear_cache (a_cache_id_list, a_response)
end end
end end
a_response.clear_block_caches (a_cache_id_list)
end end
end end

View File

@@ -423,6 +423,8 @@ feature -- Blocks initialization
Result := setup.text_item_or_default ("blocks." + a_block_id + ".region", a_default_region) Result := setup.text_item_or_default ("blocks." + a_block_id + ".region", a_default_region)
end end
feature -- Block management
block_conditions (a_block_id: READABLE_STRING_8): detachable ARRAYED_LIST [CMS_BLOCK_EXPRESSION_CONDITION] block_conditions (a_block_id: READABLE_STRING_8): detachable ARRAYED_LIST [CMS_BLOCK_EXPRESSION_CONDITION]
-- Condition associated with `a_block_id' in configuration, if any. -- Condition associated with `a_block_id' in configuration, if any.
do do
@@ -476,6 +478,34 @@ feature -- Blocks initialization
end end
end end
clear_block_caches (a_block_id_list: detachable ITERABLE [READABLE_STRING_8])
-- Clear cache for block `a_block_id_list' if set,
-- otherwise clear all block caches if `a_block_id_list' is Void.
local
p,pb: PATH
dir: DIRECTORY
l_cache: CMS_FILE_STRING_8_CACHE
do
p := api.files_location.extended (".cache").extended ("blocks")
if a_block_id_list /= Void then
across
a_block_id_list as ic
loop
-- FIXME: find a smarter way to avoid conflict between block id, and other cache id.
-- however, this is only about "Cache" so not that critical if deleted by mistake.
pb := p.extended (ic.item).appended_with_extension ("html")
create l_cache.make (pb)
if l_cache.exists then
l_cache.delete
end
end
else
-- Clear all block caches.
create dir.make_with_path (p)
dir.recursive_delete
end
end
feature -- Blocks regions feature -- Blocks regions
regions: STRING_TABLE [CMS_BLOCK_REGION] regions: STRING_TABLE [CMS_BLOCK_REGION]