/// <summary> /// Loads data from persistence store /// </summary> /// <returns>A Hashtable containing the cache items.</returns> protected override Hashtable LoadDataFromStore() { lock (store) { Hashtable itemsLoadedFromStore = new Hashtable(); string[] itemNames = store.GetDirectoryNames(GenerateSearchString(storageAreaName)); foreach (string itemLocation in itemNames) { string itemName = GenerateItemLocation(itemLocation); try { IsolatedStorageCacheItem loadedItem = new IsolatedStorageCacheItem(store, itemName, this.encryptionProvider); CacheItem itemLoadedFromStore = loadedItem.Load(); itemsLoadedFromStore.Add(itemLoadedFromStore.Key, itemLoadedFromStore); } catch (IOException) { //do nothing } } return(itemsLoadedFromStore); } }
/// <summary> /// Adds new item to persistence store /// </summary> /// <param name="storageKey">Unique key for storage item</param> /// <param name="newItem">Item to be added to cache. May not be null.</param> protected override void AddNewItem(int storageKey, CacheItem newItem) { lock (store) { string storageLocation = GenerateItemLocation(storageKey); IsolatedStorageCacheItem cacheItem = new IsolatedStorageCacheItem(store, storageLocation, this.encryptionProvider); cacheItem.Store(newItem); } }
/// <summary> /// Updates the last accessed time for the specified CacheItem stored in Isolated Storage /// </summary> /// <param name="storageKey">Identifer for CacheItem to remove.</param> /// <param name="timestamp">New timestamp for CacheItem.</param> protected override void UpdateLastAccessedTime(int storageKey, DateTime timestamp) { lock (store) { string itemLocation = GenerateItemLocation(storageKey); IsolatedStorageCacheItem storageItem = new IsolatedStorageCacheItem(store, itemLocation, this.encryptionProvider); storageItem.UpdateLastAccessedTime(timestamp); } }
/// <summary> /// Updates the last accessed time for the specified CacheItem stored in Isolated Storage /// </summary> /// <param name="storageKey">Identifer for CacheItem to remove.</param> /// <param name="newTimestamp">New timestamp for CacheItem.</param> protected override void UpdateLastAccessedTime(int storageKey, DateTime newTimestamp) { lock (store) { string itemLocation = GenerateItemLocation(storageKey); IsolatedStorageCacheItem storageItem = new IsolatedStorageCacheItem(store, itemLocation, this.encryptionProvider); storageItem.UpdateLastAccessedTime(newTimestamp); } }
/// <summary> /// Loads data from persistence store /// </summary> /// <returns>A Hashtable containing the cache items.</returns> protected override Hashtable LoadDataFromStore() { lock (store) { Hashtable itemsLoadedFromStore = new Hashtable(); string[] itemNames = store.GetDirectoryNames(GenerateSearchString(storageAreaName)); foreach (string itemLocation in itemNames) { string itemName = GenerateItemLocation(itemLocation); IsolatedStorageCacheItem loadedItem = new IsolatedStorageCacheItem(store, itemName, this.encryptionProvider); CacheItem itemLoadedFromStore = loadedItem.Load(); itemsLoadedFromStore.Add(itemLoadedFromStore.Key, itemLoadedFromStore); } return itemsLoadedFromStore; } }
/// <summary> /// Updates the last accessed time for the specified CacheItem stored in Isolated Storage /// </summary> /// <param name="storageKey">Identifer for CacheItem to remove.</param> /// <param name="timestamp">New timestamp for CacheItem.</param> protected override void UpdateLastAccessedTime(int storageKey, DateTime timestamp) { lock (store) { try { string itemLocation = GenerateItemLocation(storageKey); IsolatedStorageCacheItem storageItem = new IsolatedStorageCacheItem(store, itemLocation, this.encryptionProvider); storageItem.UpdateLastAccessedTime(timestamp); } catch (IOException) { // do nothing } } }