private static function findCaches(array $cachesNames = [])
    {
        $caches = [];
        $components = Yii::$app->getComponents();
        $findAll = ($cachesNames === []);
        
        foreach ($components as $name => $component) {
            if (!$findAll && !in_array($name, $cachesNames, true)) {
                continue;
            }
            
            if ($component instanceof CacheInterface) {
                $caches[$name] = get_class($component);
            } elseif (is_array($component) && isset($component['class']) && self::isCacheClass($component['class'])) {
                $caches[$name] = $component['class'];
            } elseif (is_string($component) && self::isCacheClass($component)) {
                $caches[$name] = $component;
            } elseif ($component instanceof \Closure) {
                $cache = Yii::$app->get($name);
                if (self::isCacheClass($cache)) {
                    $cacheClass = get_class($cache);
                    $caches[$name] = $cacheClass;
                }
            }
        }
        
        return $caches;
    }