Search code examples
javacachingignitejsr107

How to use Apache Ignite as JSR 107 cache?


I figured out a JSR 107 cache would be configured as follows:

private final static CacheManager MANAGER =
             Caching.getCachingProvider().getCacheManager();
private final static Cache<Long, Map<Integer, BufferedImage>> CACHE;
private final static Cache<Long, Map<Integer, ImageIcon>> CACHE_SERIALIZABLE;
static {
    MutableConfiguration<Long, Map<Integer, BufferedImage>> config = new MutableConfiguration<>();
    MutableConfiguration<Long, Map<Integer, ImageIcon>> javaFXConfig = new MutableConfiguration<>();
    for(MutableConfiguration config0 : new MutableConfiguration[] {config, javaFXConfig}) {
        config0.setStoreByValue(false)
                .setStatisticsEnabled(true)
                .setExpiryPolicyFactory(FactoryBuilder.factoryOf(
                        new AccessedExpiryPolicy(new Duration(TimeUnit.HOURS, 1))));
    }
    CACHE = MANAGER.createCache("cache",
            config);
    CACHE_SERIALIZABLE = MANAGER.createCache("cache-serializable",
            javaFXConfig);
}

However after adding

<dependencies>
    <dependency>
        <groupId>org.apache.ignite</groupId>
        <artifactId>ignite-core</artifactId>
        <version>1.7.0</version>
    </dependency>
</dependencies>

to pom.xml the cache doesn't store any values in the value-site Maps (an example is provided at https://github.com/krichter722/ignite-storage-failure).

I would like to run a local in-memory setup with embedded Ignite only. Unfortunately there's not one "Getting started"-documentation about this use case - only complicated distributed setups and non-JSR 107/Ignite-specific configuration.

Since this is the absolute easiest use case for a caching framework it, this has to be possible.

I'm using Apache Ignite 1.7.0.


Solution

  • The problem is:

    config0.setStoreByValue(false)

    Ignite has no store by reference support. See https://github.com/cruftex/jsr107-test-zoo/blob/master/report.md#apache-ignite-1x-test

    Of course, it would be good to throw an exception, when this is tried.