# getSingletonCache method

1. @protected

Future<ObjectHolder<Object>?> getSingletonCache(

1. String name, [
2. bool allowEarlyReference = true

])
inherited

## Implementation

    @protected
    Future<ObjectHolder<Object>?> getSingletonCache(String name, [bool allowEarlyReference = true]) async {
      // 1. Check fully created singletons first (fast path)
      final singleton = _singletons[name];
      if (singleton != null) {
        return singleton;
      }

      // 2. Check for early references (only if pod is in creation)
      if (isCurrentlyCreatingSingleton(name)) {
        return synchronized(_singletons, () async {
          var obj = _earlySingletons[name];

          if (obj == null && allowEarlyReference) {
            obj ??= _singletons[name];
            obj ??= _earlySingletons[name];

            if (obj == null) {
              final factory = _singletonFactories[name];
              if (factory != null) {
                obj = await factory.get();

                if (_singletonFactories.remove(name) != null) {
                  _earlySingletons[name] = obj;
                } else {
                  obj = _singletons[name];
                }
              }
            }
          }

          return obj;
        });
      }

      return null;
    }