Is there any solution which allows to avoid usage of two maps for case when two keys are mapped to the same value? The problem: we have a server that receives two types of requests - getDataByUserID(UserID userId)
and getDataByNodeID(NodeID nodeId)
, where userId
and nodeId
have one-to-one mapping. No DB used, all data is stored in memory. There is straightforward solution - to use two maps one UserID/data
and second NodeID/data
, but I would like to avoid manipulations with two tables.
The server interface is:
void put (InetSocketAddress nodeId, String clientId, Data data);
Data get (InetSocketAddress nodeId);
Data get (String clientId);
Any suggestions are welcome.