I would like to use infinispan (7.0.2.Final) to provide persistency for my server application written in java. Before I started to implement it, I tried the simplest scenario but it did not work...
i.e I implemented two simple unit tests and I run them one after another (i.e. I run them separately).
The first test consisted only of:
Cache<Object, Object> c = new DefaultCacheManager().getCache();
c.put("key1", "value1");
And the second one:
Cache<Object, Object> c = new DefaultCacheManager().getCache();
String result = (String) c.get("key1");
but I received result = null ...
What am I doing wrong? I read on infinispan pages that should run out of the box...
The issue here is that your configuration is not clustered. By default, there is used CacheMode=LOCAL and therefore, you can't expect data replication.
Try to set up appropriate cache mode in clustering() element:
http://infinispan.org/docs/7.0.x/user_guide/user_guide.html#_configuring_cache_programmatically