You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by "javastuff.sam@gmail.com" <ja...@gmail.com> on 2016/08/30 23:44:20 UTC

LOCAL cache and EntryProcessor

1. We have a separate logic for local cache for a specific scenario, How to
find cache mode for a given cache name? 

Does below code correct or there is alternate way -

    private boolean isLocalCache(String pObjectType) {
        CacheConfiguration[] cfg =
ignite.configuration().getCacheConfiguration();
        for (CacheConfiguration aCfg : cfg) {
            if(aCfg.getName().equalsIgnoreCase(pObjectType)) {
                return aCfg.getCacheMode().equals(CacheMode.LOCAL);
            }
        }
        return false;
    }

2. What happens when EntryProcessor executed on LOCAL cache? Below style
needed or not necessary, invoke will handle it?

if(isLocalCache()) {
...
lock.lock();
long count = cache.get(key);
count = count + 1;
cache.put(key, count);
lock.unlock();
...
} else {
cache.invoke(key, new EntryProcessor(......);
}  



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/LOCAL-cache-and-EntryProcessor-tp7419.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: LOCAL cache and EntryProcessor

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

1. You can get the cache mode for a particular cache like this:

CacheMode mode =
cache.getConfiguration(CacheConfiguration.class).getCacheMode();

2. You can use invoke() with local cache like with any other cache. No need
for special handling with explicit locks.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/LOCAL-cache-and-EntryProcessor-tp7419p7422.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.