SHOW:
|
|
- or go back to the newest paste.
| 1 | public class PersonSessionCache { | |
| 2 | ||
| 3 | private static final String FORMAT_PERSON_KEY = '{0}_Person_Id'; | |
| 4 | ||
| 5 | public static Id getPersonId(){ | |
| 6 | ||
| 7 | if (Cache.Session.contains(getPersonCacheKey())){ | |
| 8 | return (Id)Cache.Session.get(getPersonCacheKey()); | |
| 9 | } | |
| 10 | return null; | |
| 11 | } | |
| 12 | ||
| 13 | public static void setPersonId(Id personId){ | |
| 14 | Cache.Session.put(getPersonCacheKey(), personId) | |
| 15 | } | |
| 16 | ||
| 17 | public static void clearCache(){ | |
| 18 | Cache.Session.remove(getPersonCacheKey()); | |
| 19 | } | |
| 20 | ||
| 21 | private static String getPersonCacheKey(){ | |
| 22 | List<String> arguments = new List<String> {UserInfo.getProfileId()}; | |
| 23 | return String.format(FORMAT_PERSON_KEY, arguments); | |
| 24 | } | |
| 25 | } |