一致性缓存驱逐策略

时间:2015-04-07 13:34:20

标签: java caching oracle-coherence

我有以下缓存配置文件, 我想为每个缓存映射添加evcition策略,比如说

MY_SEND_SMS_SIZE_CACHE

中超过5分钟的数据

MY_REG_AUTH_CACHE

中超过10天的数据

将自动删除。

我如何配置此文件?

coherence-cache-config_imos.xml

<cache-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config"
        xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config
                     coherence-cache-config.xsd">

        <caching-scheme-mapping>
                <cache-mapping>
                        <cache-name>MY_SEND_SMS_SIZE_CACHE</cache-name>
                        <scheme-name>MY_UserDistributedCache</scheme-name>
                </cache-mapping>

                <cache-mapping>
                        <cache-name>MY_REG_AUTH_CACHE</cache-name>
                        <scheme-name>MY_UserDistributedCache</scheme-name>
                </cache-mapping>


        </caching-scheme-mapping>

        <caching-schemes>

                <distributed-scheme>
                        <scheme-name>MY_UserDistributedCache</scheme-name>
                        <service-name>MY_UserDistributedCache</service-name>

                        <serializer>
                                <instance>
                                        <class-name>com.tangosol.io.pof.SafeConfigurablePofContext
                                        </class-name>
                                        <init-params>
                                                <init-param>
                                                        <param-type>String</param-type>
                                                        <param-value>
                                                                <!-- pof-config.xml path should be set -->
                                                                pof-config.xml
                                                        </param-value>
                                                </init-param>
                                        </init-params>
                                </instance>
                        </serializer>
                        <backing-map-scheme>
                                <local-scheme />
                        </backing-map-scheme>
                        <autostart>true</autostart>
                </distributed-scheme>
        </caching-schemes>

1 个答案:

答案 0 :(得分:0)

我编辑了conf文件,然后一切正常,我的意思是超过10秒的数据被驱逐

    <caching-scheme-mapping>
            <cache-mapping>
                    <cache-name>MY_SEND_SMS_SIZE_CACHE</cache-name>
                    <scheme-name>MY_UserDistributedCache</scheme-name>
            </cache-mapping>

            <cache-mapping>
                    <cache-name>MY_REG_AUTH_CACHE</cache-name>
                    <scheme-name>MY_UserDistributedCache</scheme-name>
            </cache-mapping>


    </caching-scheme-mapping>

    <caching-schemes>

            <distributed-scheme>
                    <scheme-name>MY_UserDistributedCache</scheme-name>
                    <service-name>MY_UserDistributedCache</service-name>

                    <serializer>
                            <instance>
                                    <class-name>com.tangosol.io.pof.SafeConfigurablePofContext
                                    </class-name>
                                    <init-params>
                                            <init-param>
                                                    <param-type>String</param-type>
                                                    <param-value>
                                                            <!-- pof-config.xml path should be set -->
                                                            pof-config.xml
                                                    </param-value>
                                            </init-param>
                                    </init-params>
                            </instance>
                    </serializer>
                   <backing-map-scheme>
                    <local-scheme>
                      <scheme-name>MY_REG_AUTH_CACHE</scheme-name>
                      <expiry-delay>10s</expiry-delay>
                    </local-scheme>
                </backing-map-scheme>
                    <autostart>true</autostart>
            </distributed-scheme>
    </caching-schemes>