initializeBackgroundCleanup static method
Initializes the background cleanup process.
This function sets up a periodic timer that runs the cleanup operation.
The frequency of the task can be configured using the frequency
parameter.
By default, it runs every hour.
Implementation
static void initializeBackgroundCleanup(
{required CacheAdapter adapter, Duration? frequency}) {
// Cancel any existing timer
_cleanupTimer?.cancel();
// Set up a new periodic timer
_cleanupTimer = Timer.periodic(
frequency ?? Duration(hours: 1),
(_) => performCleanup(adapter),
);
}