The following are methods for CacheBuilder.
public Object doLoad(String var)
Type: Object
The value that was cached. Cast the return value to the appropriate type.
This example creates a class called UserInfoCache that implements the CacheBuilder interface. The class caches the results of a SOQL query run against the User object.
class UserInfoCache implements Cache.CacheBuilder { public Object doLoad(String userid) { User u = (User)[SELECT Id, IsActive, username FROM User WHERE id =: userid]; return u; } }
This example gets a cached User record based on a user ID. If the value exists in the org cache, it is returned. If the value doesn’t exist, the doLoad(String var) method is re-executed, and the new value is cached and returned.
User batman = (User) Cache.Org.get(UserInfoCache.class, ‘00541000000ek4c');