[api] Altered cache key for user groups and split out code for better debugging