I have successfully started using the Azure AppFabric Caching Service, but I'm not sure what the best way to create a DataCacheFactory object is. Now I create it for every cache call, but apparently this is not an ideal way to do this ...
Some recommend calling Singleton. But I'm not sure I understand how this will be implemented (not the actual Singleton class, but how to tie it all together).
Today I have a CacheProvider class that is created for me using Ninject, where I can perform Get / Put / Remove operations. For each of these methods, I create a DataCacheFactory object and then call .GetDefaultCache () to get a DataCache object, where I call Put / Get / Remove, respectively. I do this with one method, which looks like this:
private T Cache<T>(Func<DataCache, T> cacheAction) { using (DataCacheFactory dataCacheFactory = new DataCacheFactory()) { DataCache dataCache = dataCacheFactory.GetDefaultCache(); return cacheAction(dataCache); } }
Now I'm sure this is not a very smart idea, instead I should get the DataCache object via Singleton, where the DataCacheFactory object is created only once. BUT, how will this object survive between requests? And how does it work s> 1 instance on Azure?
Hope this all makes sense and that someone with more experience than me (3 hours) can help me.
noocyte
source share