I'm not sure we should have a cache that indicates for every user if it might be a group. The problem with this kind of cache that it would still make the loading of the group slow: we still need to perform a database query for every user and the new cache needs to be big enough to fit every user to not repeat this every time the members of a group are queried after the group has been updated.
I suggest to instead maintain per wiki a set of all documents that are groups. The API could still be isGroup(DocumentReference), but instead of having a cache, the first time we get such a request for a document in a wiki, we perform a single database query on that wiki to list all groups of that wiki. Further, we have a listener on document create/update/delete to catch when a document becomes a group/is no longer a group.
That way, the storage just scales in the number of groups and not in the number of users, and on restart, we only need to perform a single database query per wiki to initialize the data structure, so we can get the members of a group that just contains users with a constant number of database queries.
This message was sent by Atlassian Jira (v9.3.0#930000-sha1:287aeb6)
If image attachments aren't displayed, see this article.