In actual fact, I would like to still have the key as an Object, but receive the value as binary. I have looked at subclassing BinaryStoreCacheStore, but each time I try and do any ExternalizableHelper call (to or fromBinary), an exception is thrown as it does not appear to understand that it is a POF type. How can I let the cachestore know about the pofcontext?
If you want a cache store that works with Binary keys/values you need to implement BinaryEntryStore http://docs.oracle.com/cd/E24290_01/coh.371/e22843/toc.htm
The methods of a BinaryEntryStore will be passed BinaryEntry instances which you can then use to get the binary keys and values or the Object keys and values etc...
Thanks. This is actually what i had been trying without any success (although i mistakenly said BinaryStoreCacheStore rather than BinaryEntryStore in the post above). When the BinaryEntryStore.store is called, i try and convert just the key back to object with:
Object o = ExternalizableHelper.fromBinary(paramBinaryEntry.getBinaryValue());
but like i mentioned above, this throws the following as it seems to think the binary is not pof.
java.io.StreamCorruptedException: invalid type: 171
First: you are calling the ExternalizableHelper.fromBinary in the wrong way, which is why it is not working. There are two versions of ExternalizableHelper.fromBinary one that takes just the binary to be deserialized and the second takes the binary and a serializer, it is the second method you need to use to deserialize POF as you need to pass in the POF context as the serializer.
Second: there is no need to call ExternalizableHelper.fromBinary as the store method is passed a BinaryEntry so you can just call getKey() on that to give you back the Object key; so in your case just use paramBinaryEntry.getKey();