public string RunWithCache()

in src/Telemetry/UserLevelCacheWriter.cs [21:55]


        public string RunWithCache(string cacheKey, Func<string> getValueToCache)
        {
            string cacheFilepath = this.GetCacheFilePath(cacheKey);
            try
            {
                if (!File.Exists(cacheFilepath))
                {
                    if (!Directory.Exists(this._azureFunctionsSqlBindingsTryUserProfileFolderPath))
                    {
                        Directory.CreateDirectory(this._azureFunctionsSqlBindingsTryUserProfileFolderPath);
                    }

                    string runResult = getValueToCache();

                    File.WriteAllText(cacheFilepath, runResult);
                    return runResult;
                }
                else
                {
                    return File.ReadAllText(cacheFilepath);
                }
            }
            catch (Exception ex)
            {
                if (ex is UnauthorizedAccessException
                    || ex is PathTooLongException
                    || ex is IOException)
                {
                    this._telemetryClient.TrackException(ex);
                    return getValueToCache();
                }

                throw;
            }
        }