类似于 Guava 的 LoadingCache,但是是双向的?

Something similar to Guava's LoadingCache, but bidirectional?

我正在使用一个允许用户更改其显示名称的帐户系统。为此,每个用户都有一个 UUID. At various points in my program, I may have a UUID and want its current display name, or I may have a current display name and I'd like to look up the UUID. Looking it up involves either a database call or http request, so I'd like to cache results in memory. I'm familiar with Guava's LoadingCache, but it seems like I'd have to create two caches (names -> UUIDs and UUIDs -> names) in order to accomplish this. This seems bug-prone, similar to how a BiMap is better than two synchronous maps 那里有类似于双向 LoadingCache 的东西吗?

对于这种情况,我不一定会担心一对缓存容易出错:您不必使两个方向保持同步,如果您不这样做,也没有真正的失败。 UUID 及其与用户的关系不会改变。

保持双向缓存正确同步是很困难的,但对于这种情况似乎有点过分了。