You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Henrik Lundahl <he...@jayway.com> on 2016/01/26 20:12:05 UTC

Can I use the JCache API for distributed caches in Apache Ignite?

Hi

I would like to configure a distributed cache with Apache Ignite using the
JCache API (JSR107, javax.cache). Is this possible?

The examples I have found either create a local cache with the JCache API
or create a distributed cache (or datagrid) using the Apache Ignite API.

Here
<http://stackoverflow.com/questions/35017564/can-i-use-the-jcache-api-for-distributed-caches-in-apache-ignite>
is the same question on Stack Overflow.


BR

--
Henrik

Re: Can I use the JCache API for distributed caches in Apache Ignite?

Posted by Henrik Lundahl <he...@jayway.com>.
Hi

Got it working by providing a config file to the getCacheManager method as
you suggested on SO. Thanks!


--
Henrik



On Tue, Jan 26, 2016 at 11:27 PM, vkulichenko <valentin.kulichenko@gmail.com
> wrote:

> Hi Henrik,
>
> JCache allows to provide provider-specific configuration when creating a
> cache. I.e., you can do this:
>
>     // Get or create a cache manager.
>     CacheManager cacheMgr = Caching.getCachingProvider().getCacheManager();
>
>     // This is an Ignite configuration object
> (org.apache.ignite.configuration.CacheConfiguration).
>     CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
>
>     // Specify cache mode and/or any other Ignite-specific configuration
> properties.
>     cfg.setCacheMode(CacheMode.PARTITIONED);
>
>     // Create a cache based on configuration create above.
>     Cache<Integer, String> cache = cacheMgr.createCache("a", cfg);
>
> Also note that partitioned mode is actually the default one in Ignite, so
> you are not required to specify it explicitly.
>
> -Val
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Can-I-use-the-JCache-API-for-distributed-caches-in-Apache-Ignite-tp2726p2731.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Re: Can I use the JCache API for distributed caches in Apache Ignite?

Posted by vkulichenko <va...@gmail.com>.
Hi Henrik,

JCache allows to provide provider-specific configuration when creating a
cache. I.e., you can do this:

    // Get or create a cache manager.
    CacheManager cacheMgr = Caching.getCachingProvider().getCacheManager();
    
    // This is an Ignite configuration object
(org.apache.ignite.configuration.CacheConfiguration).
    CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
    
    // Specify cache mode and/or any other Ignite-specific configuration
properties.
    cfg.setCacheMode(CacheMode.PARTITIONED);
    
    // Create a cache based on configuration create above.
    Cache<Integer, String> cache = cacheMgr.createCache("a", cfg);

Also note that partitioned mode is actually the default one in Ignite, so
you are not required to specify it explicitly.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Can-I-use-the-JCache-API-for-distributed-caches-in-Apache-Ignite-tp2726p2731.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.