function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ken KoellnerKen Koellner 

Apex Test Method error re Data Silo Test using Platform Cache

I wrote a class to to wrap getting data from either disk or Platform Cache.  When not available in cache, it reads the data and puts it in cache.  When in cache, it returns data from cache.  That's a pretty standard pattern.  I wrote a test class for it and that test class works fine and gets 82% coverage.

I have other tests classes that make use of other functional classes that will use my cache wrapper class.  Those tests fail with message --
caused by: cache.Org.OrgCacheException: Failed Cache.Org.contains() for key 'local.CommonConstants.namesToIdMapMap': Org cache is only supported in Data Silo tests
I did some search and can't find anything specific in the manual about testing classes that use Platform Cache and can't find anything on "Data Silo" tests.

I'm guessing some kind of mixing of data operations isn't allow and maybe you can only test Platform Cache when certain other operations do not take place.  But I can't find rules documented anywhere. 

I'm guessing I can workaround by putting a hook in to only use the cache when isRunningTest() is true if the cache wrapper class is called by the one test specific to it that doesn't do any other data work.  But I hate to guess and have my test class come crumbling down in the future from some restriction I do not understand.

Anyone have any ideas?