<?xml version="1.0" encoding="UTF-8"?>
<p:procedure xmlns:s="leaf.plugin.script" xmlns:a="http://www.leaf-framework.org/application" xmlns:ns1="uncertain.cache.action" xmlns:rs="leaf.database.rsconsumer" xmlns:p="uncertain.proc">
    <p:echo message="${/parameter/message/@layout_code}_clearing"/>
    <s:server-script><![CDATA[
            function layout_cache_clear(root,type) {
                var cache = $cache(type);
                var children = root.getChildren();
                if (!children.length) return;
                if (cache.getMap) {
                    var map = cache.getMap();
                    var keys = map.keySet().toArray();
                    for (var i = 0;i < children.length;i++) {
                        for (var j in keys) {
                            var key = keys[j];
                            if (key.indexOf(children[i].layout_code) != -1) {
                                map.remove(keys[j]);
                            }
                        }
                    }
                } else {
                    cache.clear()
                }
            }
            layout_cache_clear($ctx.parameter,'ResponseCache');
            layout_cache_clear($ctx.parameter,'DataCache');
        ]]></s:server-script>
    <p:echo message="${/parameter/message/@layout_code}_clear_success"/>
</p:procedure>