Include block caches clearing during "clear_cache" hook invocation.
This commit is contained in:
@@ -196,6 +196,8 @@ feature -- Hook: cache
|
||||
h.clear_cache (a_cache_id_list, a_response)
|
||||
end
|
||||
end
|
||||
|
||||
a_response.clear_block_caches (a_cache_id_list)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -423,6 +423,8 @@ feature -- Blocks initialization
|
||||
Result := setup.text_item_or_default ("blocks." + a_block_id + ".region", a_default_region)
|
||||
end
|
||||
|
||||
feature -- Block management
|
||||
|
||||
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.
|
||||
do
|
||||
@@ -476,6 +478,34 @@ feature -- Blocks initialization
|
||||
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
|
||||
|
||||
regions: STRING_TABLE [CMS_BLOCK_REGION]
|
||||
|
||||
Reference in New Issue
Block a user