Home
> .NET, ASP.NET, C#, Distribued Cache, Velocity > Velocity (CTP3) – How do I know if a cache region is created?
Velocity (CTP3) – How do I know if a cache region is created?
In Velocity (CTP3) we can create, remove, and clean a cache region programmatically by calling the following methods:
- DataCache.CreateRegion
- DataCache.RemoveRegion
- DataCache.ClearRegion
But there is no method to indicate if a cache region is created or not; so if I create a region which has been created already, an exception is thrown with the error code DataCacheErrorCode.RegionAlreadyExsits.
So far the walkaround is remove the cache region before creating it:
_defaultCache.RemoveRegion(DEFAULT_CACHE_REGION);
_defaultCache.CreateRegion(DEFAULT_CACHE_REGION, true);
But this is not a good approach; so I hope the Velocity team will add the feature in the next release to check if a cache region is created.
Categories: .NET, ASP.NET, C#, Distribued Cache, Velocity
Cache Region, CTP3, Velocity
Absolutely right!
I’ve same issue too. I’m using code like this:
DataCacheFactory cacheFactory = new DataCacheFactory();
DataCache cache = cacheFactory.GetCache(“Default”);
try
{
cache.CreateRegion(“Articles”, false);
}
catch {}
But I’m sure that everybody knows that is not a healty method.