none
Why aren't regions created implicitly?

    Question

  • Why is it that regions are not created implicitly when the first call to Put/Add an object to a region is made? Searching the forums it seems like having to CreateRegion and know if it already exists is a burden and I can't quite figure out why clients would want to have to create the region explicitly in the first place when the cache could determine that no such region exists and create it in a "just-in-time" fashion.
    Wednesday, June 10, 2009 12:58 AM

Answers

  • We have also debated about the fact that region creation should be automatic, but for the moment decided it should be a explicit call as it allowed clients to know if the region already exists, being used to store objects -may be- for completely un-related purpose. Kind of protection against inadvertent mistake.

    Region creation is only one-time activity, and one doesn't even need to check if region exists, just call CreateRegion and handle the exception RegionAlreadyExists exception, and start putting objects in the region, can be done in the initialization part of the application if one knows what region one is going to need.

    Post CTP3, we are planning to allow tags on the region-created by the system itself.


    MSFT
    • Marked as answer by Drew Marsh Thursday, June 11, 2009 2:37 PM
    Thursday, June 11, 2009 4:06 AM

All replies

  • Hi Drew, if you want to create/delete regions explicitly, you can use the functionality of default regions, i.e., cache APIs without the region parameter. Please refer to the API documentation for more insight.
    Amit. (Velocity Dev, MSFT)
    Wednesday, June 10, 2009 7:38 AM
  • But I want tags, so I'm forced into using regions. :)
    Wednesday, June 10, 2009 11:05 PM
  • We have also debated about the fact that region creation should be automatic, but for the moment decided it should be a explicit call as it allowed clients to know if the region already exists, being used to store objects -may be- for completely un-related purpose. Kind of protection against inadvertent mistake.

    Region creation is only one-time activity, and one doesn't even need to check if region exists, just call CreateRegion and handle the exception RegionAlreadyExists exception, and start putting objects in the region, can be done in the initialization part of the application if one knows what region one is going to need.

    Post CTP3, we are planning to allow tags on the region-created by the system itself.


    MSFT
    • Marked as answer by Drew Marsh Thursday, June 11, 2009 2:37 PM
    Thursday, June 11, 2009 4:06 AM
  • Hi Gopal,

    "Post CTP3, we are planning to allow tags on the region-created by the system itself."

    This would be a great new feature, do you think that performance could be affected when performing a "cluster-wide" getByTag instead of a getByTag from a Region that is tied to a single CacheHost? If so it would be better to have the opportunity to choose wether to use Tag support or not, eg during NamedCache creation.

    Thanks

    Andrea Colaci
    Thursday, June 11, 2009 10:37 AM
  • The above mentioned statement should be interpreted in a different way. Actually we'd be exposing system regions (regions created by the system) to the client and then the client can use those regions in the same way as normal (user-created) ones. That means GetByTag would only apply for a region.
    Cluster-wide distributed queries are something we are targeting post-V1. Hope that clarifies, thanks.
    Amit. (Velocity Dev, MSFT)
    Thursday, June 11, 2009 11:57 AM
  • Thanks for your response Gopal.

    I know a couple other threads have discussed adding an API to detect if a region already exists, I would like to add my vote for that. The cost of throwing an exception because the region already exists impacts startup costs of an application negatively. I would much rather see this in code:

    if(!myDataCache.DoesRegionExist("Foo"))
    {
       myDataCache.CreateRegion("Foo");
    }

    than what we have to do today:

    try
    {
       myDataCache.CreateRegion("Foo");
    }
    catch(Exception)
    {
       Trace.WriteLine("Foo region already existed...")
    }

    Thanks,
    Drew

    Thursday, June 11, 2009 2:47 PM
  • Thanks for your feedback Drew; though you have to keep in mind that the first piece of code would be responsible for two round trips (one for checking the existence and one for creation of the region) if the region didn’t already exist.

     

    P.S. : in the second piece of code, you should catch DataCacheException, check for RegionAlreadyExists error code and only then swallow it.


    Amit. (Velocity Dev, MSFT)
    Friday, June 12, 2009 4:05 AM