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.

About these ads
  1. August 6, 2009 at 11:37 am

    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.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: