public function writeCacheFiles(ParsedApi $parsedApi)
    {
        $writtenCacheFiles = [];

        // first delete the cache
        foreach ($parsedApi->versions as $v => $parsedClass) {
            $this->cache->deleteCache($this->api, $parsedApi->apiClass);
        }

        // then build the cache
        foreach ($parsedApi->versions as $v => $parsedClass) {
            $compileArray = $this->compileCacheFile($parsedClass, $v);

            $this->cache->writeCacheFile($this->api, $parsedApi->apiClass, $v, $compileArray);

            $writtenCacheFiles[$v] = $compileArray;
        }

        // write current and latest versions (just include return a specific version)
        $this->cache->writeCacheFile($this->api, $parsedApi->apiClass, 'latest',
            $writtenCacheFiles[$parsedApi->latestVersion]);
        $this->cache->writeCacheFile($this->api, $parsedApi->apiClass, 'current',
            $writtenCacheFiles[$parsedApi->currentVersion]);
    }