删除ehcache的所有键

时间:2019-03-19 06:34:19

标签: rest apache-camel ehcache spring-camel

我正在将Ehcache与Apache骆驼一起使用。我正在公开一个剩余端点,该端点应该从Ehcache删除所有密钥。出于某种原因,它不会在调用其余端点后删除密钥。

以下代码用于实现相同目的:

<restConfiguration component="servlet"
            bindingMode="json" />
        <rest path="/clear">
            <get uri="/ehcache">
                <to uri="direct:clear_ehcache" />
            </get>
        </rest>
<route id="clear_ehcache_001">
            <from uri="direct:clear_ehcache" />
            <setHeader headerName="CamelCacheOperation">
                <constant>CamelCacheDeleteAll</constant>
            </setHeader>
            <setHeader headerName="CamelEhcacheAction">
                <constant>REMOVE_ALL</constant>
            </setHeader>
            <to uri="ehcache://mycache" />  
</route>

由于没有错误产生,我已经坚持了一段时间。

1 个答案:

答案 0 :(得分:0)

因此它代替了以下代码:

<!-- Rest endpoint for clearing ehcache : Start -->
<restConfiguration component="servlet"
    bindingMode="json" />
<rest path="/clear">
    <get uri="/ehcache">
        <to uri="direct:clear_ehcache" />
    </get>
</rest>
<!-- Rest endpoint for clearing ehcache : End -->

<!-- Route for clearing ehcache : Start -->
<route id="clear_ehcache_001">
    <from uri="direct:clear_ehcache" />
    <log id="_logging_clear_ehcache"
        message="Clearing Ehcache records.." />
    <setHeader headerName="CamelEhcacheAction"
        id="getCamelEhCacheAction003">
        <constant>CLEAR</constant>
    </setHeader>
    <to id="_to4"
        uri="ehcache://mycache?keyType=java.lang.String&amp;valueType=java.lang.String" />

</route>
<!-- Route for clearing ehcache : End -->