public override void DeleteAll(string uniqueName) { lock (_cache) { if (_cache.ContainsKey(uniqueName)) { _cache.Remove(uniqueName); } } // find the directory. // var dir = FileItem.DirectoryHash(uniqueName); if (IsoStore.DirectoryExists(dir)) { PriorityQueue.AddStorageWorkItem(() => { lock (LockObject) { var files = IsoStore.GetFileNames(dir + "\\*"); foreach (var f in files) { var path = Path.Combine(dir, f); DeleteFileHelper(IsoStore, path); } } }); } }
public override IEnumerable <CacheItemInfo> GetItems(string uniqueName) { CacheItemInfo item; if (_cache.TryGetValue(uniqueName, out item)) { return(new CacheItemInfo[] { item }); } // find the directory. // var dir = FileItem.DirectoryHash(uniqueName); if (IsoStore.DirectoryExists(dir)) { lock (LockObject) { string[] files = null; try { files = IsoStore.GetFileNames(dir + "\\*"); } catch (IsolatedStorageException) { // intermittent IsoStore exceptions on shutdown. files = new string[0]; } List <CacheItemInfo> items = new List <CacheItemInfo>(); foreach (var f in files) { CacheItemInfo cii = FileItem.FromFileName(f); if (cii != null) { items.Add(cii); } } var orderedItems = from i in items where i.UniqueName == uniqueName orderby i.ExpirationTime descending select i; foreach (var i in orderedItems) { if (item == null) { item = i; continue; } Delete(i); } if (item != null) { _cache[uniqueName] = item; return(new CacheItemInfo[] { item }); } } } return(new CacheItemInfo[0]); }