コード例 #1
0
  @Override
  public void afterPropertiesSet() throws Exception {

    if (xMemcachedClientBuilder != null) {
      xMemcachedClientBuilder.setName(cacheName);

      this.memcachedClient = this.xMemcachedClientBuilder.build();
    }
  }
コード例 #2
0
 public static MemcachedClient createXMemcachedClient(MemcacheConfig config) {
   try {
     XMemcachedClientBuilder builder = new XMemcachedClientBuilder(config.getServers());
     builder.setSessionLocator(new KetamaMemcachedSessionLocator());
     builder.setCommandFactory(new BinaryCommandFactory());
     builder.setConnectionPoolSize(config.getConnections());
     SerializingTranscoder transcoder = new SerializingTranscoder();
     transcoder.setCompressionThreshold(config.getCompressionThreshold());
     builder.setTranscoder(transcoder);
     builder.setConnectTimeout(config.getConnectionTimeout());
     builder.setFailureMode(false);
     builder.setOpTimeout(config.getOpTimeout());
     return builder.build();
   } catch (Exception ex) {
     log.error("Failed to create XMemcachedClient", ex);
   }
   return null;
 }