/// <summary> /// Get value from cache /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key"></param> /// <returns></returns> public async static Task <T> GetFromCache <T>(string cacheFolder, string key) { DataStorageHelper <CacheObject <T> > storage = new DataStorageHelper <CacheObject <T> >(cacheFolder); //Get cache value var value = await storage.LoadAsync(key).ConfigureAwait(false); if (value == null) { return(default(T)); } else if (value.IsValid) { return(value.File); } else { //Delete old value //Do not await Delete(cacheFolder, key); return(default(T)); } }
/// <summary> /// Delete key from cache /// </summary> /// <param name="key"></param> /// <returns></returns> public static Task Delete(string cacheFolder, string key) { DataStorageHelper <object> storage = new DataStorageHelper <object>(cacheFolder); return(storage.DeleteAsync(key)); }