Garbage Collector Service is used as a register for collectors to be processed. Registering collections can be done via SilverStripe's Configuration API as this class is Configurable.
SilverStripe\GarbageCollector\GarbageCollectorService:
collectors:
- MyCollector
- MyOtherCollector
Registered collectors can be obtained statically from the service by using GarbageCollectorService::inst()->getCollectors()
.
Garbage Collection can be triggerred by calling GarbageCollectorService::inst()->process()
. You may want to implement this into a recurring method such as QueuedJobs or BuildTasks for reoccuring execution.