Hi, Yes, to add a new item to a list value of second cache Ignite will have to deserialize whole list (with all it's items) then add new item and then serialize list again. You can try to use BinaryObjects to avoid unnecessary deserialization of list items [1]. Also note, k2 and k1 data will have different distribution and adding new instance of T will requires 2 operations (as you mentioned) on different nodes.
If k2 <- k1 relation is one-to-many, there is another way to achieve the same with using SQL [2]. With this approach adding new instance will be a single operation on one node and Ignite will need just to update local index in addition, but query for k2 will be a broadcast unless the data is collocated [3]. [1] https://apacheignite.readme.io/docs/binary-marshaller#section-binaryobject-cache-api [2] https://apacheignite-sql.readme.io/docs/java-sql-api#section-sqlfieldsqueries [3] https://apacheignite.readme.io/docs/affinity-collocation On Tue, Nov 13, 2018 at 11:34 PM Ramin Farajollah (BLOOMBERG/ 731 LEX) < [email protected]> wrote: > Hi, > > Please help me structure the cache to store instances of a type, say T. > I'd like to cache the objects in two different ways: > > 1. By a unique key (k1), where the value is a single instance > 2. By a non-unique key (k2), where the value is a list of instances > > Please comment on my approach: > > - Create a cache with k1 to an instance of T. > - Create a second cache with k2 to a list of k1 keys. > - To add a new instance of T, I will have to update both caches. Will this > result in serializing the instance (in the first cache) and the list of > keys (in the send cache)? -- Assume not on-heap. > - If so, will each addition/deletion re-serialize the entire list in the > second cache? > > Thank you! > Ramin > > -- Best regards, Andrey V. Mashenkov
