Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何切换到ehcache 3的TickingTimeSource?_Java_Ehcache 3 - Fatal编程技术网

Java 如何切换到ehcache 3的TickingTimeSource?

Java 如何切换到ehcache 3的TickingTimeSource?,java,ehcache-3,Java,Ehcache 3,下面是ehcache的配置 假设我们使用的是ehcache版本3.7 <config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://www.ehcache.org/v3' xmlns:jsr107='http://www.ehcache.org/v3/jsr107' xsi:schemaLocation="http://www.ehcache.org/v

下面是ehcache的配置

假设我们使用的是ehcache版本3.7

<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
        xmlns='http://www.ehcache.org/v3'
        xmlns:jsr107='http://www.ehcache.org/v3/jsr107'
        xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.7.xsd
                            http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.7.xsd">


    <service>
        <jsr107:defaults enable-management="true" enable-statistics="true"/>

    </service>

    <cache alias="MyCache">
        <expiry>
            <ttl unit="seconds" >172800</ttl>
        </expiry>
        <heap unit="entries">1000</heap>

    </cache>




</config>

172800
1000
  • 问题是:如何切换到TickingTimeSource,如ehcache文档中所述
  • 到目前为止完成的作业:-

    • 已尝试在ehcache xsd文件-->中搜索TickingTimeSource的配置标记,目前没有任何线索
    • 在ehcache 3代码库中搜索github-->中示例代码的TickingTimeSource切换,到目前为止没有任何线索
    • 只是想在新的ehcache 3上通过配置来压缩性能攻击。发现ehcache 3中不支持LRU逐出策略。存在AgainstRejectionAdvisor(防止驱逐的逻辑,我想这对性能没有帮助)
    • 在ehcache google groups->到目前为止没有答案中检查类似查询的答案
    • 已检查github->中的样本ehcache配置gists文件,但到目前为止未找到TickingTimeSource的相关配置
    • 在使用ehcache的地方进行了java代码调试,检查了内部变量/对象,并搜索了设置TimeSource——这可能为注入TickingTimeSource提供了线索。发现需要在内部存储对象(JSR107Store或ehcacheStore)中设置时间源,但它没有提供直接设置时间源的api

    我发现只有通过基于Java的配置才能实现这一点。我还没有时间对此进行测试,但此代码与我在ehcache测试中发现的代码类似:

    CacheManager cacheManager =
        CacheManagerBuilder.newCacheManagerBuilder()
                .using(new TimeSourceConfiguration(new TickingTimeSource(1L, 1000L)))
                .withCache("cache1",
                        CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, Object.class, ResourcePoolsBuilder.heap(10))).build(true)
    

    我发现只有通过基于Java的配置才能实现这一点。我还没有时间对此进行测试,但此代码与我在ehcache测试中发现的代码类似:

    CacheManager cacheManager =
        CacheManagerBuilder.newCacheManagerBuilder()
                .using(new TimeSourceConfiguration(new TickingTimeSource(1L, 1000L)))
                .withCache("cache1",
                        CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, Object.class, ResourcePoolsBuilder.heap(10))).build(true)