user1184777
user1184777

Reputation: 1027

infinispan 9 '<eviction strategy="LRU" />' isn't an allowed element

Wildfly 18 eviction tag is not parsing giving Failed to parse configuration error. this is coming when i upgrade Wildfly 11 to 18. In wildfly 11 (infinispan 4) its working fine

    <subsystem xmlns="urn:jboss:domain:infinispan:4.0">
        <cache-container name="security" default-cache="auth-cache">
            <local-cache name="auth-cache">
                <locking acquire-timeout="${infinispan.cache-container.security.auth-cache.locking.acquire-timeout}"/>
                <eviction strategy="LRU" max-entries="${infinispan.cache-container.security.auth-cache.eviction.max-entries}"/>
                <expiration max-idle="-1"/>
            </local-cache>
        </cache-container>
    </subsystem>

In Wildfly 18 having below section (NOT WORKING)

    <subsystem xmlns="urn:jboss:domain:infinispan:9.0">
        <cache-container name="security" default-cache="auth-cache">
            <local-cache name="auth-cache">
                <locking acquire-timeout="${infinispan.cache-container.security.auth-cache.locking.acquire-timeout}"/>
                <eviction strategy="LRU" max-entries="${infinispan.cache-container.security.auth-cache.eviction.max-entries}"/>
                <expiration max-idle="-1"/>
            </local-cache>
        </cache-container>
    </subsystem>

Its giving ^^^^ 'eviction' isn't an allowed element here.infinispan:9.4 its says Eviction is configured by adding the but even that gives unrecognized tag memory.

how to add eviction strategy=LRU or replacement to strategy:"LRU"=?

Upvotes: 3

Views: 1668

Answers (2)

Lonzak
Lonzak

Reputation: 9816

According to the docs in infinispan 9.0 eviction is configured by adding the <memory/> element to your <*-cache/> configuration sections. Eviction is handled by Caffeine utilizing the TinyLFU algorithm with an additional admission window. This was chosen as provides high hit rate while also requiring low memory overhead. This provides a better hit ratio than LRU while also requiring less memory than LIRS. In general there are two types:

  • COUNT (This type of eviction will remove entries based on how many there are in the cache. Once the count of entries has grown larger than the size then an entry will be removed to make room.
  • MEMORY - This type of eviction will estimate how much each entry will take up in memory and will remove an entry when the total size of all entries is larger than the configured size. This type only works with primitive wrapper, String and byte[] types, thus if custom types are desired you must enable storeAsBinary. Also MEMORY based eviction only works with LRU policy.

So I would think you define it like that:

<cache-container name="security" default-cache="auth-cache">
    <local-cache name="auth-cache">
        <...your other options...>
        <object-memory/>
    </local-cache>
</cache-container>

OR

<binary-memory eviction-type="MEMORY/COUNT"/>

OR

off-heap-memory eviction-type="MEMORY/COUNT"/>

AND you can always specify the size:

size="${infinispan.cache-container.security.auth-cache.eviction.max-entries}"

Storeage types:

  • object-memory (Stores entries as objects in the Java heap. This is the default storage type. Storage type supports COUNT only so you do not need to explicitly set the eviction type. Policy=TinyLFU)
  • binary-memory (Stores entries as bytes[] in the Java heap. Eviction Type: COUNT OR MEMORY. Policy=TinyLFU)
  • off-heap-memory (Stores entries as bytes[] in native memory outside the Java. Eviction Type: COUNT OR MEMORY. Policy=LRU)

Upvotes: 3

Paul Ferraro
Paul Ferraro

Reputation: 121

Lonzak's reponse is correct. Additionally, you can just use your "urn:jboss:domain:infinispan:4.0" configuration from WildFly 9 in WildFly 19. WildFly will automatically update the configuration to its equivalent in the current schema version.

Upvotes: 0

Related Questions