@Test public void createWithBaseConf() throws IOException { CacheConfiguration conf = new CacheConfiguration(); conf.setConsistentHashing(true); conf.setOperationTimeout(1000); conf.setUseBinaryProtocol(false); CacheClient client = factory.create(addrs, conf); assertNotNull(client); client.shutdown(); }
@Override public CacheClient create(final List<InetSocketAddress> addrs, final CacheConfiguration conf) throws IOException { XMemcachedClientBuilder builder = null; if (conf instanceof XMemcachedConfiguration) { int[] weights = ((XMemcachedConfiguration) conf).getWeights(); if (weights != null && weights.length > 0) { builder = new XMemcachedClientBuilder(addrs, weights); } } if (builder == null) { builder = new XMemcachedClientBuilder(addrs); } if (conf.isConsistentHashing()) { builder.setSessionLocator(new KetamaMemcachedSessionLocator()); } if (conf.isUseBinaryProtocol()) { builder.setCommandFactory(new BinaryCommandFactory()); } builder.setTranscoder(new SerializingTranscoder(CachedObject.MAX_SIZE)); if (conf instanceof XMemcachedConfiguration) { setProviderBuilderSpecificSettings(builder, (XMemcachedConfiguration) conf); } MemcachedClient client = builder.build(); if (conf.getOperationTimeout() != null) { client.setOpTimeout(conf.getOperationTimeout()); } if (conf instanceof XMemcachedConfiguration) { setProviderClientSpecificSettings(client, (XMemcachedConfiguration) conf); } return new MemcacheClientWrapper(client); }
MemcacheClientFactoryImpl implements CacheClientFactory { @Override public CacheClient create(final List<InetSocketAddress> addrs, final CacheConfiguration conf) throws IOException { XMemcachedClientBuilder builder = null; if (conf instanceof XMemcachedConfiguration) { int[] weights = ((XMemcachedConfiguration) conf).getWeights(); if (weights != null && weights.length > 0) { builder = new XMemcachedClientBuilder(addrs, weights); } } if (builder == null) { builder = new XMemcachedClientBuilder(addrs); } if (conf.isConsistentHashing()) { builder.setSessionLocator(new KetamaMemcachedSessionLocator()); } if (conf.isUseBinaryProtocol()) { builder.setCommandFactory(new BinaryCommandFactory()); } builder.setTranscoder(new SerializingTranscoder(CachedObject.MAX_SIZE)); if (conf instanceof XMemcachedConfiguration) { setProviderBuilderSpecificSettings(builder, (XMemcachedConfiguration) conf); } MemcachedClient client = builder.build(); if (conf.getOperationTimeout() != null) { client.setOpTimeout(conf.getOperationTimeout()); } if (conf instanceof XMemcachedConfiguration) { setProviderClientSpecificSettings(client, (XMemcachedConfiguration) conf); } return new MemcacheClientWrapper(client); } }
MemcacheClientFactoryImpl implements CacheClientFactory { @Override public CacheClient create(final List<InetSocketAddress> addrs, final CacheConfiguration conf) throws IOException { XMemcachedClientBuilder builder = null; if (conf instanceof XMemcachedConfiguration) { int[] weights = ((XMemcachedConfiguration) conf).getWeights(); if (weights != null && weights.length > 0) { builder = new XMemcachedClientBuilder(addrs, weights); } } if (builder == null) { builder = new XMemcachedClientBuilder(addrs); } if (conf.isConsistentHashing()) { builder.setSessionLocator(new KetamaMemcachedSessionLocator()); } if (conf.isUseBinaryProtocol()) { builder.setCommandFactory(new BinaryCommandFactory()); } builder.setTranscoder(new SerializingTranscoder(CachedObject.MAX_SIZE)); if (conf instanceof XMemcachedConfiguration) { setProviderBuilderSpecificSettings(builder, (XMemcachedConfiguration) conf); } MemcachedClient client = builder.build(); if (conf.getOperationTimeout() != null) { client.setOpTimeout(conf.getOperationTimeout()); } if (conf instanceof XMemcachedConfiguration) { setProviderClientSpecificSettings(client, (XMemcachedConfiguration) conf); } return new MemcacheClientWrapper(client); }  }
MemcacheClientFactoryImpl implements CacheClientFactory { @Override public CacheClient create(final List<InetSocketAddress> addrs, final CacheConfiguration conf) throws IOException { XMemcachedClientBuilder builder = null; if (conf instanceof XMemcachedConfiguration) { int[] weights = ((XMemcachedConfiguration) conf).getWeights(); if (weights != null && weights.length > 0) { builder = new XMemcachedClientBuilder(addrs, weights); } } if (builder == null) { builder = new XMemcachedClientBuilder(addrs); } if (conf.isConsistentHashing()) { builder.setSessionLocator(new KetamaMemcachedSessionLocator()); } if (conf.isUseBinaryProtocol()) { builder.setCommandFactory(new BinaryCommandFactory()); } builder.setTranscoder(new SerializingTranscoder(CachedObject.MAX_SIZE)); if (conf instanceof XMemcachedConfiguration) { setProviderBuilderSpecificSettings(builder, (XMemcachedConfiguration) conf); } MemcachedClient client = builder.build(); if (conf.getOperationTimeout() != null) { client.setOpTimeout(conf.getOperationTimeout()); } if (conf instanceof XMemcachedConfiguration) { setProviderClientSpecificSettings(client, (XMemcachedConfiguration) conf); } return new MemcacheClientWrapper(client); }  @Override CacheClient create(final List<InetSocketAddress> addrs, final CacheConfiguration conf); }
MemcacheClientFactoryImpl implements CacheClientFactory { @Override public CacheClient create(final List<InetSocketAddress> addrs, final CacheConfiguration conf) throws IOException { XMemcachedClientBuilder builder = null; if (conf instanceof XMemcachedConfiguration) { int[] weights = ((XMemcachedConfiguration) conf).getWeights(); if (weights != null && weights.length > 0) { builder = new XMemcachedClientBuilder(addrs, weights); } } if (builder == null) { builder = new XMemcachedClientBuilder(addrs); } if (conf.isConsistentHashing()) { builder.setSessionLocator(new KetamaMemcachedSessionLocator()); } if (conf.isUseBinaryProtocol()) { builder.setCommandFactory(new BinaryCommandFactory()); } builder.setTranscoder(new SerializingTranscoder(CachedObject.MAX_SIZE)); if (conf instanceof XMemcachedConfiguration) { setProviderBuilderSpecificSettings(builder, (XMemcachedConfiguration) conf); } MemcachedClient client = builder.build(); if (conf.getOperationTimeout() != null) { client.setOpTimeout(conf.getOperationTimeout()); } if (conf instanceof XMemcachedConfiguration) { setProviderClientSpecificSettings(client, (XMemcachedConfiguration) conf); } return new MemcacheClientWrapper(client); }  @Override CacheClient create(final List<InetSocketAddress> addrs, final CacheConfiguration conf);  }