server/api/common/cache-topo-graph-converter.js
/**
   * Read converted topology data from cache file.
   * @returns {Promise<ForceSimulationTopologyData>} Converted topology data object from cache.
   * @private
   */
Read converted topology data from cache file.
@returns {Promise} Converted topology data object from cache.
@private
Read converted topology data from cache file . @returns { Promise } Converted topology data object from cache . @private
async _readForceSimulationTopologyDataFromCacheJSON() {
    console.log('use cache: ', this._cacheJsonPath)
    try {
      const buffer = await readFile(this._cacheJsonPath)
      return JSON.parse(buffer.toString())
    } catch (error) {
      console.error('Error: cannot read cache: ', this._cacheJsonPath)
      fs.unlink(this._cacheJsonPath, (error) => {
        if (error) {
          throw error
        }
        console.warn(
          `Warning: server removes cache ${this._cacheJsonPath}. Retry request again.`
        )
      })
      throw error
    }
  }
async _readForceSimulationTopologyDataFromCacheJSON ( ) { console . log ( 'use cache: ' , this . _cacheJsonPath ) try { const buffer = await readFile ( this . _cacheJsonPath ) return JSON . parse ( buffer . toString ( ) ) } catch ( error ) { console . error ( 'Error: cannot read cache: ' , this . _cacheJsonPath ) fs . unlink ( this . _cacheJsonPath , ( error ) => { if ( error ) { throw error } console . warn ( ` ${ this . _cacheJsonPath } ` ) } ) throw error } }
Read converted topology data from cache file.
Read converted topology data from cache file .
// this function is called after checking operative cache existence (_foundOperativeCache()) // exception in readFile() for cache json means error in json (contents).