Ejemplo n.º 1
0
        private bool Get(string key, DateTime lastModifiedUtc, out CachedData cachedData)
        {
            string cacheFileName = GetCacheFilePath(key);

            try
            {
                if (!C1File.Exists(cacheFileName) || C1File.GetCreationTimeUtc(cacheFileName) != lastModifiedUtc)
                {
                    cachedData = null;
                    return(false);
                }

                cachedData = _deserializer(cacheFileName);
            }
            catch (Exception ex)
            {
                Log.LogWarning(LogTitle, "Failed to load cached data. Cache '{0}', file: '{1}'", cacheFileName);
                Log.LogWarning(LogTitle, ex);

                cachedData = null;
                return(false);
            }
            return(true);
        }