Search code examples
c#.netignitegridgain

Apache Ignite: How to cache an entry with multiple keys


Is there any way to cache one entry against two keys in apache ignite? say for eg: I need to cache users, based on their user id and their username, so I can get it back in both ways. Which is the best way to achieve this?


Solution

    1. Use two caches, from Id to User (ICache<Guid, User>) and from UserName to Id ICache<string, Guid>

    2. Use one cache ICache<Guid, User>, and create an SQL index on UserName column https://ignite.apache.org/docs/latest/SQL/indexes