// cache hit
Cache.replace(cacheKey, userPerms, "6mn"); // keep cache warm
return new JsonParser().parse(userPerms).getAsJsonObject();
} else {
// cache miss
WSRequest req = WS.url(oauth.instance_url
+ "/services/data/v28.0/sobjects/%s/describe/", "PermissionSet");
req.headers.put("Authorization", "OAuth " + oauth.access_token);
HttpResponse response = req.get();
int res = response.getStatus();
if (res == 200) {
JsonElement jsonResult = response.getJson();
Cache.set(cacheKey, jsonResult.toString(), "6mn");