locked
Removing items from cache................. RRS feed

  • Question

  • User-192792487 posted

    I am using the caching application block to cache objects from the BLL. In my “Manager” class I have various methods (GetSomething, GetAll, Insert, Update, Delete etc.)

     

    For example when the “GetSomething” method is called I check if the item exists in the cache if not the code gets the item and caches it with the following key

     

    Something_Cache_ + something.SomethingID

     

    When I call the “GetAll” method I cache it with this key

     

    Something_Cache_

     

    Now in my Insert, Update and Delete methods I would like to remove everything in cache that starts with Something_Cache_

     

    What would be the code

     

    cacheManager.Remove(StartsWith(“Something_Cache_”)

     

    would that work or is there a better way???

     

    Cheers,

     

    N

    Wednesday, November 1, 2006 4:17 PM

All replies

  • User-192792487 posted

    Tried this but still without success:

    private static void PurgeCacheItems()

    {

    List<string> itemsToRemove = new List<string>();

    while (cacheManager.Contains(AVATARIMAGE_KEY.StartsWith(AVATARIMAGE_KEY)))

    {

    itemsToRemove.Add(AVATARIMAGE_KEY);

    }

    foreach(string itemToRemove in itemsToRemove)

    {

    cacheManager.Remove(itemToRemove);

    }

    }

    Wednesday, November 1, 2006 8:40 PM