Cache Exceptions

The Cache namespace contains exception classes.

All exception classes support built-in methods for returning the error message and exception type. See Exception Class and Built-In Exceptions in the Apex Developer Guide.

The Cache namespace contains these exceptions.

ExceptionThrown when
Cache.Session.SessionCacheExceptionAn error occurred while adding or retrieving a value in the session cache.
Cache.Session.SessionCacheNoSessionExceptionAn attempt is made to access the cache when the session cache isn’t available.
Cache.Org.OrgCacheExceptionAn attempt is made to access a partition that doesn’t exist or whose name is invalid.
Cache.InvalidParamExceptionAn invalid parameter value is passed into a method of Cache.Session or Cache.Org. This error occurs when:
  • The key referenced is null or empty or is not alphanumeric.
  • The key isn’t qualified with the namespace and partition in the format <namespace>.<partition>.<key>.
  • The key isn’t qualified in the format <key> for the default partition, or for a key inserted through the partition object.
  • The namespace referenced is null or empty.
  • The partition name is null or empty or is not alphanumeric.
  • Another referenced value is null.
Cache.ItemSizeLimitExceededExceptionA cache put call is made with an item that exceeds the maximum size limit. To fix this error, break the item into multiple, smaller items.
Cache.BulkApiKeysLimitExceededExceptionThe number of key parameters passed into a bulk method - get(keys) or contains(setOfKeys) exceeds the maximum limit of 10.
Cache.PlatformCacheInvalidOperationExceptionA cache put or remove call is made that is not allowed. For example, when calling put or remove inside a Visualforce constructor.
Cache.CacheBuilderExecutionExceptionThis error occurs when the execution of the CacheBuilder fails; this could be due to an error in parsing, a permissions error while accessing records, or an issue with Apex callouts.
Cache.InvalidCacheBuilderExceptionA get(CacheBuilder cb, String key), remove(CacheBuilder cb, String key), or validateCacheBuilder(CacheBuilder cb) method is called but the cb parameter is a class that does not implement the Cache.CacheBuilder interface.