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
KruviKruvi 

Static class in memory

Hi

 

I'm wondering if it is possible to write a class that once a single instance is created it will be stored in memory, or the only way to achieve persistence between different execution threads is through the database?

 

Many thanks

 

Kruvi

Best Answer chosen by Admin (Salesforce Developers) 
Andy BoettcherAndy Boettcher

Probably sObject.

All Answers

Andy BoettcherAndy Boettcher

APEX Classes will stay resident in memory for the duration of your execution.  Once your execution has completed - it will shut down.

 

If there are variables or something that you want to stay resident - you'd have to go the sObject or Custom Settings route.

 

-Andy

KruviKruvi

Thank you Andy

 

I need to maintain a queue which is being filled by a trigger and dequeued by some other process that sends a callout.

What do you recommend, Custom settings or sObject?

 

Thanks a lot

 

 

Andy BoettcherAndy Boettcher

Probably sObject.

This was selected as the best answer