how to know the connection is connected. does spymemcached thread safe?

95 views
Skip to first unread message

David Luo

unread,
Nov 1, 2014, 1:41:30 AM11/1/14
to spymem...@googlegroups.com
I want to use spymemcached in our production.

I have some questions:
Question 1:
does spymemcached thread safe? like can I create one instance and use it in multi thread to get/set(I only need to get and set)?


Question 2:
how to know that the ClientConnection is connected or not.
I find that new MemcachedClient will never throw Exception.
this is how I do:

        try {

           mc = new MemcachedClient( new InetSocketAddress( host, port ) );

            mc.get( "test" );

            available = true;

        } catch( OperationTimeoutException e ) {

            available = false;

            mc.shutdown();

        } catch( ConnectException e ) {

            available = false;

            mc.shutdown();

        } catch( IOException e ) {

            available = false;

            mc.shutdown();

        }

do you have better way????


Reply all
Reply to author
Forward
0 new messages