7

While I doubt the speculation that I put in the title is correct, from time to time my default cache partition (10MB trial) gets emptied within less than an hour.

There are about 20 keys in there, each taking up around 600 bytes. I am setting the TTL to the maximum 48hr value, therefore the cache cannot be dying. I am not able to pinpoint the whenabouts but so far I have seen it happen after running unit tests, executing an anonymous block, and refreshing the Org Cache Diagnostics page. All of them hit the cache.

With regards to the Diagnostics page my experience has been bizarre: I populated the cache about 2 hours ago with 19 keys, then just 5 minutes ago when I refreshed the Org Cache Diagnostics page 10 of the entries were gone. I refreshed the page after 1 minute and this time got an internal server error! With the next refresh the error was gone but so were all the remaining values in the cache. There were no code changes, deployments, or unit tests during this period.

So my question is, are there any other reasons beside those documented on the official Platform Cache Limits page that might be contributing to this seemingly random eviction of my values?

2
  • did you ever get a resolution on this with regards to a case? Commented Jul 8, 2020 at 20:57
  • 1
    @KrisGoncalves No. I ended up dropping platform cache from my design.
    – Mossi
    Commented Jul 9, 2020 at 3:12

1 Answer 1

5

Reading the limitations page, the first two points are probably of interest:

  • Cache isn’t persisted. There’s no guarantee against data loss.
  • Some or all cache is invalidated when you modify an Apex class in your org.

My reading of the first is that even if you set the TTL to 48 hours, there is no guarantee that the cache actually keeps the data alive that long. Anonymous apex may count as "modifying an Apex class," as well.

4
  • My thought is that running a test may count as a deployment, even if nothing is modified, which falls under the "modifying an Apex Class" as well.
    – sfdcfox
    Commented Sep 23, 2017 at 22:10
  • It's none of the above. I will tell you why exactly: I populated the cache about 2 hours ago with 19 keys, then just 5 minutes ago when I refreshed the Org Cache Diagnostics page 10 of the entries were gone. I refreshed the Diagnostics page after 1 minute and this time got an internal server error! With the next refresh the error was gone but so were all the remaining values in the cache. There were no code changes, deployments, or unit tests during this period.
    – Mossi
    Commented Sep 27, 2017 at 5:56
  • @Mossi You should probably open a case, any answer someone on this site could provide would just be speculation. Commented Sep 27, 2017 at 11:28
  • @IllusiveBrian There is an ongoing case already, but in the meantime I thought to see if others have experienced this behaviour too.
    – Mossi
    Commented Sep 27, 2017 at 17:11

You must log in to answer this question.

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