ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kevin <kevin.c...@leonardo.com>
Subject Re: Cache read through when invoking EntryProcessor?
Date Tue, 06 Oct 2015 19:47:35 GMT
Hi Val, I created a short test. I'm using Ignite 1.4


> public class Test {
>     public static void main (String[] args) {
>         Ignite ignite = Ignition.start();
>         CacheConfiguration
> &lt;
> Integer, String
> &gt;
>  cacheConfiguration = new CacheConfiguration<>("mycache");
>         IgniteReflectionFactory
> <TestCacheStore>
>  factory = new IgniteReflectionFactory<>(TestCacheStore.class, true);
>         cacheConfiguration.setCacheStoreFactory(factory);
>        
> cacheConfiguration.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
>         cacheConfiguration.setReadThrough(true);
>         cacheConfiguration.setWriteThrough(true);
>         cacheConfiguration.setIndexedTypes(Integer.class, String.class);
> 
>         IgniteCache
> &lt;
> Integer, String
> &gt;
>  cache = ignite.getOrCreateCache(cacheConfiguration);
> 
>         cache.invoke(1, (entry, arguments) -> {
>             System.out.println("x " + entry.getValue());
>             return null;
>         });
> 
>         System.out.println("y " + cache.get(1));
> 
>         cache.invoke(1, (entry, arguments) -> {
>             System.out.println("z " + entry.getValue());
>             return null;
>         });
>     }
> 
>     public static class TestCacheStore extends CacheStoreAdapter
> &lt;
> Integer, String
> &gt;
>  {
>         @Override
>         public String load(Integer key) throws CacheLoaderException {
>             return "hi";
>         }
> 
>         @Override
>         public void write(Cache.Entry<? extends Integer, ? extends String>
> entry) throws CacheWriterException {
> 
>         }
> 
>         @Override
>         public void delete(Object key) throws CacheWriterException {
> 
>         }
>     }
> }

Output:
x null
x null
x null
y hi
z hi
z hi
z hi



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Cache-read-through-when-invoking-EntryProcessor-tp1557p1559.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message