1 Reply Latest reply on Apr 30, 2014 10:43 AM by mircea.markus

    Using the KeyAffinityService, how to be able to do cache.get(...) when I dont control the keys?

    jakob.skwarski

      Say I have a class Person

       

      class Person {

           String firstName;

           String lastName;

           String fromCountry;

          

           //And other fields....

           ...

           ...

      }

       

      I want to be able to put objects into a cluster with some key. Normally I would use, for example, firstName+lastName+fromCountry as a key and then from anywhere in the cluster be able to get that Person with just the name and country. Now lets say I use the KeyAffinityService so I get a key by which I will add some Person into some specific node with the key generated by the service. How can I then do cache.get operations? The keys are generated by the service and given a Person object I have, as far as I understand it, no control of how the key is generated so I have no way to make a cache.get(key) operation given that I only know the name and country of some Person. Im quite new to Infinispan and maybe I am missing something basic here....