We are using Apache Ignite for caching in a Scala application. For caching we use Scala case class as the cache key which has 2 parameter list. The cachekey is as follows:
case class CacheKey(p1:String=null, p2:String=null) (ex1:String=null,ex2:String=null) {}
I am using the second param list to send some additional attributes to the Ignite server which is read in my Cache store implementation.
By default, Scala case class creates hashCode() and equals() using the fields in the first param list. Which means ex1 and ex2 will be ignored from hashCode() and equals().
I have verified this to be true by creating simple test cases as well.
My expectations are that if my ignite cache has an entry with the key as CacheKey("p1", "p2")(null, null) I should get a cache hit when I try to get the cached value using the same values for p1 and p2 but any different values for ex1 and ex2
I would expect CacheKey("p1", "p2")("e1", "e2") to get a cache hit. However that is not the case even though both the keys are equal.
Am I missing something?
PS: I have tested the results using setOnheapCacheEnabled as both true and false. It did not have any effect on the results.
Ignite stores its data in "binary object" format. It does not use the hashCode and equals methods to determine equality. If you have optional properties, they would need to be part of the value object.