标签: ehcache

Redis还是Ehcache?

哪个更适合以下环境:

  1. 坚持不是强迫.
  2. 多个服务器(必须要求Ehcache一些缓存同步).
  3. 不经常写入和频繁读取.
  4. 相对较小的数据库(内存需求非常少).

我现在会倒出脑子里的东西.我可能错了.

我知道Redis需要一个单独的服务器(?),Ehcache提供本地缓存,因此它必须更快,但会跨服务器复制缓存(?).使用Ehcache可以在更新一个缓存后更新所有缓存.

我的问题是哪个更符合我提到的环境?
谁的表现会更好,或者什么样的表现可能比另一个表现更好?

提前致谢.

spring caching ehcache redis spring-boot

18
推荐指数
2
解决办法
2万
查看次数

Hibernate和EHCache:maxElementsInMemory如何工作?

我已经为EHCache配置了一个defaultCache(用于元素),一个StandardQueryCache(用于查询)和UpdateTimestampsCache(我认为是为了跟踪数据库更新......但我并没有真正得到它所做的一切).

我为每个缓存设置了maxElementsInMemory,但我没有得到的是这个数字控制StandardQueryCache和UpdateTimestampsCache的内容.我知道可以在默认缓存中缓存的实体数量不得超过10000,但查询缓存不会缓存元素.它缓存主键(据我所知).

这是否意味着StandardQueryCache的maxElementsInMemory控制结果中的"行"数,或者它是否控制了它可能具有的元素的主键对数?

那么UpdateTimestampsCache呢?它是否跟踪实体上次更新的时间,上次更新表的时间......或其他内容?我应该为maxElementsInMemory使用哪个号码?

谢谢!

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true" monitoring="autodetect"     dynamicConfig="true">
  <defaultCache 
    maxElementsInMemory="10000"
    eternal="false"
    timeToIdleSeconds="3600"
    timeToLiveSeconds="3600">
  </defaultCache>

  <cache
    name="org.hibernate.cache.internal.StandardQueryCache"
    maxElementsInMemory="10000"
    eternal="false"
    timeToIdleSeconds="3600"
    timeToLiveSeconds="3600">
  </cache>

  <cache
    name="org.hibernate.cache.spi.UpdateTimestampsCache"
    maxElementsInMemory="10000"
    eternal="true">
  </cache>

</ehcache>
Run Code Online (Sandbox Code Playgroud)

configuration hibernate ehcache

17
推荐指数
1
解决办法
2万
查看次数

如何使用Hibernate 3.5.2配置JPA 2.0以将EHCache用作二级缓存和查询缓存?

我找到了一些如何配置纯hibernate以使用EHCache的说明.但我找不到任何说明如何配置JPA2.0 EntityManager来使用缓存.Hibernate 3.5.2是我的JPA2.0提供程序.

编辑// @Cacheable(true)对于实体来说足够了吗?或者我应该使用@org.hibernate.annotations.Cache配置实体?

orm hibernate ehcache second-level-cache jpa-2.0

16
推荐指数
1
解决办法
2万
查看次数

使用hibernate,hibernate注释和ehcache的Maven依赖是什么?

我想用最新的hibernate,hibernate-annotations和ehcache依赖项来更新我的Maven pom.xml.

我阅读了hibernate下载页面和ehcache donwload页面.我试图解释它似乎都失败了.有人可以写出应该进入pom.xml的片段吗?

Cryptic hibernate下载页面:http: //hibernate.org/downloads

Cryptic ehcache下载页面:http: //www.terracotta.org/dl/ehcache-oss-download-catalog

这是我到目前为止:

   <properties>
       <hibernate.version>3.6.0.Final</hibernate.version>
   </properties>
   <dependencies>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>${hibernate.version}</version>
        <exclusions>
            <exclusion>
                <groupId>javax.transaction</groupId>
                <artifactId>jta</artifactId>
            </exclusion>
            <exclusion>
                <groupId>net.sf.ehcache</groupId>
                <artifactId>ehcache</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-ehcache</artifactId>
        <version>${hibernate.version}</version>
        <exclusions>
            <exclusion>
                <groupId>net.sf.ehcache</groupId>
                <artifactId>ehcache</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache</artifactId>
        <version>2.2.0</version>
        <type>pom</type>
    </dependency>
 </dependencies>

    <repositories>
        <repository>
            <id>codehaus-repository</id>
            <name>Codehaus</name>
            <url>https://nexus.codehaus.org/content/repositories/releases/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>java.net</id>
            <url>http://download.java.net/maven/1</url>
            <layout>legacy</layout>
        </repository>
        <repository>
            <id>central</id>
            <name>Maven Repository Switchboard</name>
            <layout>default</layout>
            <url>http://repo1.maven.org/maven2</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>sonatype-ehcache</id>
            <url>http://oss.sonatype.org/content/repositories/sourceforge-releases</url>
            <layout>default</layout>
        </repository> …
Run Code Online (Sandbox Code Playgroud)

dependencies hibernate ehcache maven

16
推荐指数
1
解决办法
8万
查看次数

Ehcache关闭在运行测试套件时导致异常

我遇到了以下问题.

我的项目中有一套测试服,每个测试都运行良好.

但是,当我将它们作为套件运行时,我们中的一些会因以下异常而失败:

Caused by: java.lang.IllegalStateException: The dao Cache is not alive (STATUS_SHUTDOWN)
    at net.sf.ehcache.Cache$CacheStatus.checkAlive(Cache.java:4269)
    at net.sf.ehcache.Cache.checkStatus(Cache.java:2703)
    at net.sf.ehcache.Cache.get(Cache.java:1576)
    at org.springframework.cache.ehcache.EhCacheCache.get(EhCacheCache.java:61)
    at org.springframework.cache.interceptor.CacheAspectSupport.inspectCacheables(CacheAspectSupport.java:310)
    at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:198)
    at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:66)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
Run Code Online (Sandbox Code Playgroud)

有没有办法避免这种行为,即在多次测试中保持缓存活着还是正确关闭?

spring ehcache spring-test junit4

16
推荐指数
1
解决办法
1万
查看次数

没有参数方法的@Cacheble注释

我希望@Cacheable在没有参数的方法上有注释.在这种情况下,我使用@Cacheable如下

@Cacheable(value="usercache", key = "mykey")
public string sayHello(){
    return "test"
}
Run Code Online (Sandbox Code Playgroud)

但是,当我调用此方法时,它不会被执行,并且如下所示会出现异常

org.springframework.expression.spel.SpelEvaluationException:EL1008E:(pos 0):在'org.springframework.cache.interceptor.CacheExpressionRootObject'类型的对象上找不到属性或字段'mykey' - 可能不公开?

请建议.

spring ehcache spelevaluationexception

16
推荐指数
2
解决办法
1万
查看次数

JPA的Write-Behind Cache

从这里和整个网络搜索看来,不可能将EHCache实现为Hibernate的后写缓存,因为这需要对Hibernate代码进行大量更改.

JPA提供程序是否有任何其他解决方案(最好是开源)可以"透明地"挂钩到后写缓存实现,最好是可以像Terracotta一样分发的解决方案?

我已经读过EclipseLink和Oracle Coherence可以实现这一点,但Coherence可悲的不是一个廉价的解决方案!

java hibernate terracotta jpa ehcache

15
推荐指数
1
解决办法
2052
查看次数

EHCache中的EH代表什么?

出于好奇心,谷歌没有给我答案,但EH在EHCache中代表什么?

java ehcache

15
推荐指数
1
解决办法
3119
查看次数

Spring框架中的ehcache配置

我试图从RSS源加载一些上下文,并在春天使用ehcache库将其作为缓存传递给客户端.这是我的代码:

    import org.springframework.cache.annotation.Cacheable;
@Service
public class GlossaryReaderService {

    @Cacheable(value = "glossaryList")
    public List<Glossary> readGlossary(String url) {

        XmlReader reader = null;
        List<Glossary> extractedGlossay = new ArrayList<Glossary>();
        SyndEntry entry;
        SyndContent desc;
        Glossary glossaryList = null;
        try {
            String decodedURL = URLDecoder.decode(url, "UTF-8");
            reader = new XmlReader(new URL(decodedURL));
            SyndFeed feed = new SyndFeedInput().build(reader);

            for (Iterator i = feed.getEntries().iterator(); i.hasNext();) {
                entry = (SyndEntry) i.next();
                desc = entry.getDescription();
                if (desc != null) { ...
                        extractedGlossay.add(glossaryList);
                    }
                }
            }

        } catch (IOException | IllegalArgumentException | …
Run Code Online (Sandbox Code Playgroud)

spring ehcache spring-cache spring-4

15
推荐指数
2
解决办法
4万
查看次数

Ehcache和MultiThreading

ehcache默认是支持多线程还是需要进行任何配置更改?在使用Ehcache的多线程我的应用程序时,我发现数据库命中数实际上在增加,即所有线程都没有可用的全局缓存,尽管我的缓存都是单例.有什么建议?

java multithreading ehcache

14
推荐指数
1
解决办法
1万
查看次数