I'm using org cache to store the results of a call to the google maps geocode api. Just noticed, the caching doesn't seem to work in a Sandbox.

You can see how I'm storing/accessing here:

public static Location getGeocode(String query){
        if (query != null) {
            String q = query.toLowerCase().replaceAll('[^a-zA-Z0-9]', '');
            Cache.OrgPartition orgPart = Cache.Org.getPartition('local.GoogleMaps');
            if (orgPart != null){
                if (orgPart.contains(q)) {
                    return (Location)orgPart.get(q);
            ... calling google maps, parsing the response
            center = Location.newInstance((Decimal)loc.get('lat'), (Decimal)loc.get('lng'));
            orgPart.put(q, center);
            return center;
    return null;

So works as expected in prod, we don't get charged twice if someone looks up the same string too quickly.

But in the sandbox. Nothing gets added to the cache and I still have 0% cache usage.

This method is called via a @AuraEnabled(Cacheable=true) method, and in the sandbox, caching is turned off. But I didn't think that'd disabled the platform cache for direct calls, right?

If I open an Execute Anonymous window in the dev console, I can add something to the cache and then access it again with another statement, so It seems the cache works.

Any ideas? Asking more for knowledge/documentation purposes!

  • 1
    I don't have any documantation to support it but we found that saving apex classes can cause the cache to lose data. Our cache code has always been unstable in sandboxes in which there is constant development. Is your sandbox a shared sandbox?
    – gNerb
    Commented Apr 16, 2020 at 19:04
  • 1
    Can confirm. Saving an Apex class does indeed reset the platform cache. Saw this behavior consistently when working in a sandbox. Commented Jun 3, 2021 at 11:25


You must log in to answer this question.

Browse other questions tagged .