Reputation: 437
I wanted to use Infinispan today in a sort of probably unfamiliar matter. I want to save a Variable, let's call it x a couple of times in the cache - while being able to adress it as X.
Plain, old MVCC. However, it seems that infinispan uses MVCC on the backend - but I wasn't able to use it in my little test-application.
This is the corresponding code:
acTest.put("test", "blubber", 0, TimeUnit.MILLISECONDS );
acTest.put("test", "nothing", 0, TimeUnit.MILLISECONDS );
if( acTest.containsKey("test") )
{
Object foo = acTest.get("test"); // don't know how to get the "blubber" out of that
String name = (String) test2.get("name");
System.out.println(name);
}
Sure enough, acTest contains the key - but I was not able to adress the value "blubber" of that key - when I higher the numerical value of "nothing" foo holds "nothing" ... but I want to get the first version of "foo" - hence "blubber"
I want to be able to adress the different versions of test. I think that I can create different versions of "test" with the different parameters in the put operation - however eclipse has absolutely no documentation for that matter ...
Could somebody help me?
Upvotes: 0
Views: 350
Reputation: 6107
Infinispan uses MVCC in it's container for internal purposes, this is currently not a feature exposed via user API, besides via writeSkewCheck.
In version 5.1 the API will expose Optimistic locking, which might be useful for some use cases needing to take advantage of the MVCC capabilities, but you still won't be able to extract a previous value.
You could use AtomicMap to store multiple values, or use custom key objects containing the version, building what you need on top of Infinispan's API.
DeltaAware is another option, but it's a low-level interface meant for experts.
Upvotes: 1