我正在尝试使用EntLib将解决方案转换为使用AppFabric缓存.借助一些扩展方法,这是一个相当痛苦的过程.
我使用的扩展方法:
public static bool Contains(this DataCache dataCache, string key)
{
return dataCache.Get(key) != null;
}
public static object GetData(this DataCache dataCache, string key)
{
return dataCache.Get(key);
}Run Code Online (Sandbox Code Playgroud)
但是我发现EntLib有两个很难转换的功能.即"Count"(计算缓存中的键数)和"Flush"(从缓存中删除所有数据).如果我可以迭代缓存中的密钥,两者都可以解决.
有一个方法被调用ClearRegion(string region),但是我需要在我使用的所有Get/Put/Add方法上指定一个区域名称,这需要一些手动容易出错的工作.
有没有办法获取缓存中的密钥列表?
我可以使用默认的区域名称吗?
如果我没有使用区域名称,如何刷新缓存?