membase smart client intended usage
Fri, 10/15/2010 - 15:19
I'm using the membase 1.0.3 java smart client, talking to a specific bucket. I had some general questions about how to use the client.
1. Is it ok to call ClientManager.getClient() every time I want to access the cache, or is there overhead in calling getClient() such that I need to cache the MemcachedClient for a while?
2. Do I have to call MemcachedClient.shutdown() after each call to ClientManager.getClient(), or is it intended that the ClientManager will take care of this behind the scenes?
3. Will the ClientManager do the right thing to reconnect to a bucket if I delete that bucket and recreate it?
With #1, it's actually the intended usage that you call getClient regularly. You should only keep a reference to a given MemcachedClient for a short period of time, like that of a method. The ClientManager will keep the MemcachedClient around, and always give you the reference to the most up-to-date object.
On #2, no need to call the shutdown() until you're actually shutting down your application. It can (and should!) live for a long time in a typical application.
On #3, the client manager may exit if you delete the bucket, but if you try to reinstantiate it after recreating the bucket it should be fine.
Hope that helps,
- Matt