[infinispan-issues] [JBoss JIRA] (ISPN-8319) Restore mechanism to manipulate Weigher implementation used by Caffeine
Dan Berindei (Jira)
issues at jboss.org
Wed Oct 30 13:15:00 EDT 2019
[ https://issues.jboss.org/browse/ISPN-8319?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dan Berindei reassigned ISPN-8319:
----------------------------------
Assignee: Will Burns
> Restore mechanism to manipulate Weigher implementation used by Caffeine
> -----------------------------------------------------------------------
>
> Key: ISPN-8319
> URL: https://issues.jboss.org/browse/ISPN-8319
> Project: Infinispan
> Issue Type: Enhancement
> Components: Eviction
> Affects Versions: 9.1.0.Final
> Reporter: Paul Ferraro
> Assignee: Will Burns
> Priority: Major
>
> Infinispan 9.1 allows a user to manipulate the Weigher implementation used by Caffeine to by configuring a cache with a custom DataContainer that uses a specific EntrySizeCalculator implementation. However, the DataContainerConfiguration object is deprecated, suggesting that a future release will no longer expose a mechanism for doing this. Such a mechanism is necessary to allow users to exempt specific cache entries (while allowing others) from eviction.
> One proposal is to allow users to specify an EntrySizeCalculator via the MemoryConfigurationBuilder.
> e.g.
> {code:java}
> public interface EntrySizeCalculatorProvider {
> <K, V> EntrySizeCalculator<K, V> getEntrySizeCalculator();
> }
> {code}
> MemoryConfigurationBuilder.java:
> {code:java}
> public MemoryConfigurationBuilder.entrySizeCalculatorProvider(EntrySizeCalculatorProvider provider) {
> // ...
> }
> {code}
> Additionally, we can reinterpret EvictionType as a specific EntrySizeCalculatorProvider implementation.
> e.g. MemoryConfigurationBuilder.java:
> {code:java}
> private static final Map<EvictionType, EntrySizeCalculatorProvider> PROVIDERS = new EnumMap<>(EvictionType.class);
> static {
> PROVIDERS.put(EvictionType.COUNT, new EntrySizeCalculatorProvider() {
> public <K, V> EntrySizeCalculator<K, V> getEntrySizeCalculator() {
> return (key, value) -> 1L;
> }
> });
> PROVIDERS.put(EvictionType.MEMORY, new EntrySizeCalculatorProvider() {
> public <K, V> EntrySizeCalculator<K, V> getEntrySizeCalculator() {
> return new WrappedByteArraySizeCalculator<>(new PrimitiveEntrySizeCalculator());
> }
> });
> }
> MemoryConfigurationBuilder evictionType(EvictionType type) {
> this.entrySizeCalculatorProvider(PROVIDERS.get(type));
> return this;
> }
> {code}
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
More information about the infinispan-issues
mailing list