首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Infinispan缓存商店

Infinispan缓存商店
EN

Stack Overflow用户
提问于 2015-04-13 00:34:22
回答 1查看 1.2K关注 0票数 0

我想使用Infinispan缓存存储而不是LevelDb缓存存储。

下面是我的配置:

代码语言:javascript
复制
<infinispan
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
                       urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
   xmlns="urn:infinispan:config:6.0"
   xmlns:jdbc="urn:infinispan:config:jdbc:6.0" >
    <global>
        <globalJmxStatistics enabled="false" allowDuplicateDomains="true"/>
    </global>

    <!-- Define the cache loaders (i.e., cache stores). Passivation is false
     because we want *all* data to be persisted, not just what doesn't fit
     into memory. -->
    <persistence>
        <mixedKeyedJdbcStore fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
            <simpleConnection connectionUrl="jdbc:postgresql://localhost:5432/infinispan_binary_based" driverClass="org.postgresql.Driver" username="postgres" password="postgres"/>
            <stringKeyedTable prefix="ISPN_MIXED_STR_TABLE" createOnStart="true" dropOnExit="true">
                <idColumn name="ID_COLUMN" type="VARCHAR(255)" />
                <dataColumn name="DATA_COLUMN" type="BINARY" />
                <timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
            </stringKeyedTable>
            <binaryKeyedTable prefix="ISPN_MIXED_BINARY_TABLE" createOnStart="true" dropOnExit="true">
                <idColumn name="ID_COLUMN" type="VARCHAR(255)" />
                <dataColumn name="DATA_COLUMN" type="BINARY" />
                <timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
            </binaryKeyedTable>
        </mixedKeyedJdbcStore>
    </persistence>
</namedCache>

但我一直有个例外:

代码语言:javascript
复制
Message: Unexpected element '{urn:infinispan:config:jdbc:6.0}mixedKeyedJdbcStore'  
  at org.infinispan.configuration.parsing.ParserRegistry.parseElement(ParserRegistry.java:139) [infinispan-core-6.0.2.Final.jar:6.0.2.Final]  
  at org.infinispan.configuration.parsing.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:37) [infinispan-core-6.0.2.Final.jar:6.0.2.Final]  
  at org.infinispan.configuration.parsing.Parser60.parsePersistence(Parser60.java:558) [infinispan-core-6.0.2.Final.jar:6.0.2.Final] 

我从依赖项中删除了leveldb缓存存储jar,并将其替换为jdbc缓存存储jar。

你能告诉我我错过了什么吗?请帮帮忙?

提前谢谢你。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-14 12:01:30

您正在声明一个名为jdbc的命名空间,但不使用它。您需要在mixedKeyedJdbcStore中的所有标记前加上jdbc:,或者使用默认名称空间,如下所示:

代码语言:javascript
复制
<infinispan
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:infinispan:config:6.0 http://www.infinispan.org/schemas/infinispan-config-6.0.xsd
                   urn:infinispan:config:jdbc:6.0 http://www.infinispan.org/schemas/infinispan-cachestore-jdbc-config-6.0.xsd"
    xmlns="urn:infinispan:config:6.0"
    xmlns:jdbc="urn:infinispan:config:jdbc:6.0" >
<global>
    <globalJmxStatistics enabled="false" allowDuplicateDomains="true"/>
</global>

<!-- Define the cache loaders (i.e., cache stores). Passivation is false
 because we want *all* data to be persisted, not just what doesn't fit
 into memory. -->
<namedCache name="testCache">
    <persistence>
        <mixedKeyedJdbcStore xmlns="urn:infinispan:config:jdbc:6.0" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
            <simpleConnection connectionUrl="jdbc:postgresql://localhost:5432/infinispan_binary_based" driverClass="org.postgresql.Driver" username="postgres" password="postgres"/>
            <stringKeyedTable prefix="ISPN_MIXED_STR_TABLE" createOnStart="true" dropOnExit="true">
                <idColumn name="ID_COLUMN" type="VARCHAR(255)" />
                <dataColumn name="DATA_COLUMN" type="BINARY" />
                <timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
            </stringKeyedTable>
            <binaryKeyedTable prefix="ISPN_MIXED_BINARY_TABLE" createOnStart="true" dropOnExit="true">
                <idColumn name="ID_COLUMN" type="VARCHAR(255)" />
                <dataColumn name="DATA_COLUMN" type="BINARY" />
                <timestampColumn name="TIMESTAMP_COLUMN" type="BIGINT" />
            </binaryKeyedTable>
        </mixedKeyedJdbcStore>
    </persistence>
</namedCache>

您的配置也缺少了一个启动的namedCache标记,但我认为这是一个复制错误,否则错误消息将是不同的。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29596287

复制
相关文章

相似问题

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