Updating appfabric cache when file changes

Réponse proposée Updating appfabric cache when file changes

  • samedi 9 juin 2012 17:02
     
      A du code

    Hi,

    I'm using appfabric cache like this -

    DataCache dataCache = dataCacheFactory.GetDefaultCache();
    if (dataCache.Get("myCacheData") == null)
                {
                    string path = MapPath("App_Data/CacheData.txt");
    
                    // Open the file to read from.
                    readText = File.ReadAllLines(path);
                    dataCache.Put("myCacheData", readText);
                }
                else
                {
                    readText = (string[])dataCache.Get("myCacheData");
                }

    However, how do I ensure that everytime the contents in CacheData.txt changes, the cahce value also gets updated.

    Am I using this incorrectly?

    Thanks!


    Coffee

    • Déplacé Darren GosbellMVP mardi 12 juin 2012 04:16 this is an AppFabric question (From:SQL Server Analysis Services)
    •  

Toutes les réponses

  • mercredi 13 juin 2012 06:07
     
     

    Hi,

    'CacheData.txt' file contents are specific to your application , right ? When you add item to the cache you can set expiry to a value that you think the contents can get modified. When each time item gets expired you will update the cache with latest file contents. Depending on the period set there might me time period you get stale data. Let me know if this work for you.

    Thanks

    Arun


    arunks

  • mercredi 13 juin 2012 13:27
     
     Réponse proposée

    Thanks for the response.

    It would be nice if there was a dynamic mechanism whereby if the user changed the data, appfabric would detect the change and self load the new document contents into cache on the fly.

    Thanks.


    Coffee