Memecached Javaclient must initialize the Sockiopool before it is used, which has only one protected construction method, so the external need to use the static method provided by it getinstance to obtain the Sockiopool instance. The GetInstance method allows incoming poolname to indicate the Sockiopool name. Sockiopool itself is only as a Schoonersockiopool proxy class, Schoonersockiopool maintains a connection pool map, where poolname as key, Pool instance as a value. So when you use spring to consolidate memcacheds, if you indicate poolname in the spring configuration file, you need to specify poolname in its constructor when initializing Memecachedclient. If no poolname is declared, memechachedclient or gets the pool instance named default.
For the following configuration, you must pass in the poolname when Memechacedclient is instantiated. Otherwise, data operations or data operations will not be available.
Spring configuration file, which declares Sockiopool, because the class is constructed with a protected type and cannot be accessed directly, you need to use the factory method getinstance () to get the example, note: here < The constructor-arg> label is not an argument for a constructor, but rather as a parameter to the factory method getinstance (), indicating that poolname is Memcache
<bean id= "Memcache" class= "Com.whalin.MemCached.SockIOPool" factory-method= "getinstance" Initialize "destroy-method=" ShutDown "><constructor-arg> <value>memcache</value> </constructor-arg><property name= "Servers" > <list> <value>${memcache.server}</value> </list> </ property> <property name= "Initconn" > <value>${memcache.initConn}</value> </property> & Lt;property name= "Minconn" > <value>${memcache.minConn}</value> </property> <property name= "
Maxconn "> <value>${memcache.maxConn}</value> </property> <property name=" Maintsleep "> <value>${memcache.maintSleep}</value> </property> <property name= "Nagle" > <value>${m emcache.nagle}</value> </property> <property name= "Socketto" > <value>${memcache.socketto}& Lt;/value> </property> </bean>
When you use Memcachedclient to access memchached, you must indicate that poolname is memcache (default defaults, but default is not configured in the configuration file)
Memcachedclient memcachedclient = new Memcachedclient ("Memcache");
Memcachedclient.set ("name", "simple");
System.out.println (Memcachedclient.get ("name"));
When Memcachedclient is instantiated here, the parameter ' Memcache ' class must be passed in to indicate the pool instance name, otherwise there will be no error at insertion, but the read value will always be null