Can spy default to localhost even with a list of memcached addresses?

28 views
Skip to first unread message

Devlin McGregor

unread,
Jun 3, 2013, 2:55:26 PM6/3/13
to spymem...@googlegroups.com
Not sure if this is possible, but we're using 2.8.1 on grails/groovy, client set up as follows...

MemcachedClient c=new MemcachedClient(
       
AddrUtil.getAddresses("localhost:11211 cachecluster:11211"));



We deploy memcached on each app server node, so we prefer doing operations against the local memcached for low latency, but if local memcached fails, spy fails over to cachecluster, which is a group of remote memcacheds. Obviously, the fail over part is good for HA, but if the local memcached comes back, we'd want the client to start using it again and not the cluster address.

We tested the above with default settings. All sets/gets went to localhost, then we killed localhost; all operations failed over to cachecluster, but after bringing back localhost, the client was stuck on the cachecluster address.

So is there a way to prefer the first address in the list, in our case, localhost?

ingenthr

unread,
Jun 5, 2013, 3:16:28 AM6/5/13
to spymem...@googlegroups.com
There isn't a method for this built in, but you can implement a NodeLocator to do so.  It wouldn't be super hard, but it's a bit complicated because of needing to manage the rebuilding of the connection.

Some source which does something similar to this is the CouchbaseClient, which builds on spymemcached.

Hope that helps,

Matt
Reply all
Reply to author
Forward
0 new messages