首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何切换到ehcache 3的TickingTimeSource?

如何切换到ehcache 3的TickingTimeSource?
EN

Stack Overflow用户
提问于 2019-04-26 11:10:09
回答 1查看 234关注 0票数 1

下面是ehcache的配置,

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

代码语言:javascript
复制
<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>
  1. 问题是:如何切换到TickingTimeSource,如ehcache文档这里中所提到的

到目前为止所做的作业:-

  • 试图在ehcache xsd文件中搜索TickingTimeSource的配置标记-到目前为止还没有线索。
  • 在ehcache 3代码库中搜索TickingTimeSource切换,以获取github中的示例代码-到目前为止还没有线索。
  • 只是试图在新的ehcache 3上使用配置来压缩性能,发现ehcache 3中不支持LRU驱逐策略。有AgainstEvictionAdvisor (防止驱逐的逻辑,我想这对性能没有帮助)
  • 在ehcache google组中查找类似查询的答案->至今没有答案
  • 从github ->中检查了示例ehcache配置要点文件,但到目前为止还没有找到TickingTimeSource的相关配置。
  • 在使用ehcache的地方进行java代码调试,检查内部变量/对象并搜索设置TimeSource --这可能会给注入TickingTimeSource提供线索。发现,TimeSource需要在内部存储对象( JSR107Store或ehcacheStore )中设置,但它没有提供直接设置时间源的api。
EN

回答 1

Stack Overflow用户

发布于 2020-02-25 12:14:10

我找到了一种通过基于Java的配置来实现这一目标的方法。我还没有时间对此进行测试,但这段代码与我在ehcache测试中发现的类似:

代码语言:javascript
复制
CacheManager cacheManager =
    CacheManagerBuilder.newCacheManagerBuilder()
            .using(new TimeSourceConfiguration(new TickingTimeSource(1L, 1000L)))
            .withCache("cache1",
                    CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, Object.class, ResourcePoolsBuilder.heap(10))).build(true)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55866367

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档