windows azure caching - best practice for checking whether a key exist or not

我们两清 提交于 2019-12-24 18:27:48

问题


In Windows Azure Caching (http://msdn.microsoft.com/en-us/library/windowsazure/hh914161.aspx), Microsoft.ApplicationServer.Caching.DataCacheException is thrown (with ErrorCode: KeyDoesNotExist), when someone tries to get a not-cached object (i.e., the key of the object does not exist).

Instead of handling DataCacheException, is there any way to check if the key exists gracefully?

thanks,


回答1:


The DataCache.Get(key) method returns null if the provided key is not found.

Any other methods that require the key to be present such as those concerned with locking will result in a DataCacheException.



来源:https://stackoverflow.com/questions/14551129/windows-azure-caching-best-practice-for-checking-whether-a-key-exist-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!