clearSingletonCache method

  1. @override
void clearSingletonCache()

Clears all cached singleton pods.

This method is useful for resetting the singleton registry without affecting other pod registries or configurations. Typically used during application shutdown or reconfiguration.

Example:

final registry = MySingletonPodRegistry();

// Populate cache with multiple singletons
registry.registerSingleton('userService', UserService());
registry.registerSingleton('productService', ProductService());

print(registry.getSingletonCount()); // 2

// Clear all cached singletons
registry.clearSingletonCache();

// Cache is now empty
print(registry.getSingletonCount()); // 0

Implementation

@override
void clearSingletonCache() {
  getPodFactory().clearSingletonCache();

  if (_parent != null) {
    _parent!.getPodFactory().clearSingletonCache();
  }
}