I'm using session cache and trying to set the TTL (lifetime) to 60 minutes. However it is expiring much more quickly (it appears to be using the default 5 minute expiry). The docs say TTLs is seconds not milliseconds. Do I need to override the default TTLs at the partition or platform level as well?

private void putTokenInCache(String token) {
    if (token != null) {
        Cache.Session.put('token', token, 3600);
  • That documentation says the maximum value is 8 hours. Have you tried setting that value as if it were milliseconds? Because a maximum of 28.8k ms would not even be a 5 minute timeout.
    – Adrian Larson
    Jan 17, 2019 at 21:38
  • Do this I shall.
    – Shanerk
    Jan 17, 2019 at 21:46
  • If this is true, by the way, that it's milliseconds, make sure you log a lot of doc bugs. Because there's no mention of millisecond expiry anywhere in cache that I could find.
    – sfdcfox
    Jan 17, 2019 at 21:49
  • Nope 16:50:34:249 FATAL_ERROR cache.Org.OrgCacheException: Failed Cache.Session.put() for key 'token': Session Cache TTL, 360000, above maximum allowed: 28800 secs
    – Shanerk
    Jan 17, 2019 at 21:51
  • If it's the session cache then it would expire along with the corresponding Salesforce session, regardless of how long the ttlSecs was. In which context are you adding the value to the cache? Salesforce creates different child sessions as you navigate different areas. I wonder if changes in the child session is forcing the expiry or otherwise preventing access to the cached values. Jan 22, 2019 at 20:24


You must log in to answer this question.

Browse other questions tagged .