Infinispan - 按实体设置expiration.lifespan [英] Infinispan - set per Entity expiration.lifespan

查看:101
本文介绍了Infinispan - 按实体设置expiration.lifespan的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Jboss 6.1.0上部署了一个java Web应用程序,它使用infinispan 5.2.6.Final。
我正在尝试按照本指南设置每个实体特定的 expiration.lifespan

I have a java web application deployed on Jboss 6.1.0, that uses infinispan 5.2.6.Final. I'm trying to set a per Entity specific expiration.lifespan following this guide

http://infinispan.org/docs/5.2.x/user_guide/user_guide.html#_advanced_configuration_2

我的实体bean com.myenterprise.myproject.dal.ejb.entity.RefStatus。

for my Entity bean com.myenterprise.myproject.dal.ejb.entity.RefStatus.

指南声明如下:


您还可以在每个实体/集合
类型的基础上覆盖逐出/过期设置,使得覆盖设置仅涉及特定的
实体(即com.acme.Person)或集合类型(即com.acme.Person.addresses)。
例如:

You can also override eviction/expiration settings on a per entity/collection type basis in such way that the overriden settings only afftect that particular entity (i.e. com.acme.Person) or collection type (i.e. com.acme.Person.addresses). For example:



<property name="hibernate.cache.infinispan.com.acme.Person.expiration.lifespan" value= "65000"/>

因此,我已将以下元素添加到我的persistence.xml中,以将生命周期缩短为10用于测试目的的毫秒数,以便稍后进行微调:

So, i've added the following element to my persistence.xml, to reduce the lifespan to 10 milliseconds for test purposes, in order to fine tune it later:

<property name="hibernate.cache.infinispan.com.myenterprise.myproject.dal.ejb.entity.RefStatus.expiration.lifespan" value= "10"/>

该设置不会产生任何影响,而且寿命仍然是默认设置。

The setting produces no effects and the lifespan remains the default.

您知道如何设置persistence.xml以成功覆盖默认的到期生命周期吗?
设置

Do you know how I have to set the persistence.xml to successfully override the default expiration lifespan? Setting the

<property name="hibernate.cache.infinispan.entity.expiration.lifespan" value= "10"/>

它有效,但它会影响所有实体缓存,而且它不是我想要的。

it works, but it affects all entity caches, and it is not what I want.

以下是我的application.xml文件:

What follows is my application.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
    <persistence-unit name="myProject_dal_PU" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>java:jboss/datasources/myProject-DataSource</jta-data-source>
        <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
        <properties>
            <property name="hibernate.archive.autodetection" value="class" />
            <property name="hibernate.bytecode.use_reflection_optimizer" value="true" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.format_sql" value="false" />

            <property name="hibernate.cache.use_second_level_cache" value="true" />
            <property name="hibernate.cache.use_minimal_puts" value="true" />
            <property name="hibernate.cache.use_query_cache" value="true" />
            <property name="hibernate.cache.infinispan.com.myenterprise.myproject.dal.ejb.entity.RefStatus.expiration.lifespan" value= "10"/>
        </properties>
    </persistence-unit>
</persistence>

谢谢。

推荐答案

如果您在应用程序服务器中运行,除了实体名称之外,您还必须提供部署名称和单元。因此,所有这些过期属性都需要添加前缀: hibernate.cache.infinispan。< warname>。< unitname>。<实体的FQN> ...

If you are running within the application server, apart from the entity name, you have to provide the deployment name and unit too. So, all such expiration properties need to be prepended with: hibernate.cache.infinispan.<warname>.<unitname>.<FQN of entity>...

在您的情况下,我不知道您的部署名称,但是您提到的单位和FQN,如:

In your case, I don't know the name of your deployment, but with the unit and FQN that you mention, something like:

hibernate.cache.infinispan。< warname> .myProject_dal_PU.com.myenterprise.myproject.dal.ejb.entity.RefStatus.expiration.lifespan

这篇关于Infinispan - 按实体设置expiration.lifespan的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆