1

I was experimenting with Platform Cache and stumbled upon CacheBuilder interface which looks robust for our use cache. The only problem is how can I set time to live in this interface? By default it will be 24hours, I want to set it as 2 hours.

Code:

class UserInfoCache implements Cache.CacheBuilder {
    public Object doLoad(String userid) {
        User u = (User)[SELECT Id, IsActive, username FROM User WHERE id =: userid];
        return u;
    }

Usage:

User batman = (User) Cache.Org.get(UserInfoCache.class, ‘00541000000ek4c');

Soure: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_cache_CacheBuilder.htm

1 Answer 1

3

This looks like a limitation of CacheBuilder usage.

Cache builder writes and reads data from the cache for you and there's no way you can set the cache TTL when using it as you can see in the documentation: Safely Cache Values with the CacheBuilder Interface

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .