Moving from memcached to Couchbase
Mon, 06/25/2012 - 03:42
I understand that Couchbase can be a drop-in replacement for memcached, but I have a couple of questions.
Right now I have an application that talks to a memcached server by:
1. Creating an instance of net.spy.memcached.MemcachedClient
2. Connecting to localhost:11211
3. All kinds of get/set fun and profit
However looking at the examples given in the Couchbase docs, I see that
1. The client object is actually a com.couchbase.client.CouchbaseClient (I assume this is a superset of the Spymemcached functionality)
2. Connections are made to http://127.0.0.1:8091/pools rather than port 11211
Is this correct? What happens if, for instance, I create a CouchbaseClient and point it to localhost:11211?
Thanks
Glenn.
1. CouchbaseClient extends MemcachedClient so all you need to do is change the constructors in your ode and everything should work. The only other differences between these two classes are CouchbaseClient contains a few more apis that allow you to do operations only implemented in Couchbase.
2. When you create a CouchbaseClient you will actually point it to something like "http://localhost:8091/pools". This wil connect the client to our streaming api that tells the client all about your Couchbase cluster. Using this information the client will make connections to port 11211 for you. There is a little bit more to this, but you can basically think of "http://localhost:8091/pools" as a magic url that takes care of the entire connection process for you.
Let me know if you have any other questions.