Reputation: 3328
In the Pivotal Native Client I've setup a method to read and write a Geode cache region as follows:
public void GeodePut(string region, string key, string value)
{
CacheFactory cF = CacheFactory.CreateCacheFactory();
Cache c cF.Create();
RegionFactory rF = c.CreateRegionFactory(RegionShortcut.CACHING_PROXY);
IRegion<string, string> r = rF.Create<string, string>(region);
r[key] = value;
cache.Close();
}
when I call this multiple times I get RegionExistsException
how do I get around that? Thanks
Upvotes: 0
Views: 590
Reputation: 86
Solution is easy. Add a try-catch block to catch the RegionExistsException, then in the catch segment replace the 'create' method with 'get'. Change this: rF.Create for this: rf.get This works pretty well using Java, i would post the exact signature of the method you needed but im not using .Net native client.
Hope it helps :)
Upvotes: 1
Reputation: 3328
It's to do with the cache.Close()
command. I no longer use cache.Close()
Upvotes: 0