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
Samuel WolfeSamuel Wolfe 

Session cache is not persisting

We are trying to store a value in a session cache partition. When I add values to the session cache, appears to be stored successfully for the duration of 1 debug log.

However when I list all the data from the session cache, it appears to be cleared every time a new debug log is started. We never explcitily clear the session cache.

Any idea why this could be happening?

Here is the code where I store the value in the partition:
Cache.SessionPartition apicache  = Cache.Session.getPartition('local.APICache.'+hash);
            apicache.put(hash, json);
Here is how we retrieve data from the partition
Cache.SessionPartition apicache = Cache.Session.getPartition('local.APICache.'+hash);

This successfully stores and retrieves the data through the duration of 1 debug log. But when I initiate the code again (aka by clicking a link to an object), it is no longer there.

5MB has been allocated to the session cache partition.
 
Best Answer chosen by Samuel Wolfe
Samuel WolfeSamuel Wolfe
Update: So it looks like there is a delay after changing your cache partition size. The cache won't start working until a while after. Also in general it seems to stop working again at random.