Garbage collection¶
Default strategy¶
$stratifiedPersist->garbageCollector([
CatalogManager::class,
CatalogSettingsManager::class,
ProductManager::class,
TagManager::class,
ProductTagManager::class,
]);
The default DeleteByBuildStrategy executes one delete per obsolete strate and manager, filtered by buildStrate.
A build is obsolete when:
- it belongs to the same scope and scope id as a release pointer;
- it is older than the currently released build;
- its status is
building,releasedorfailed.
After business rows are collected, the build is marked garbage_collected. Garbage-collected build metadata is then deleted. Failed-build metadata older than the configured threshold is also deleted.
Managers that were not registered in StratifiedPersist are ignored by garbageCollector().
Configure options¶
use Small\SwooleEntityManager\Strates\Config\StratifiedPersistOptions;
$options = new StratifiedPersistOptions(
garbageCollectorStrategy: null,
failedBuildMaxAgeHours: 48,
);
failedBuildMaxAgeHours must be greater than zero. null selects DeleteByBuildStrategy.
Partition strategy¶
use Small\SwooleEntityManager\Strates\GarbageCollector\PartitionGarbageCollectorStrategy;
$options = new StratifiedPersistOptions(
garbageCollectorStrategy: new PartitionGarbageCollectorStrategy(),
failedBuildMaxAgeHours: 24,
);
Partition names are derived from the UUID:
MySQL executes:
PostgreSQL executes:
The package does not create, attach or route partitions. The application schema and insertion strategy must already follow this naming convention.