use of net.spy.memcached.spring.MemcachedClientFactoryBean in project cas by apereo.
the class MemcachedTicketRegistryConfiguration method memcachedClient.
@Lazy
@Bean
public MemcachedClientFactoryBean memcachedClient() {
try {
final MemcachedClientFactoryBean bean = new MemcachedClientFactoryBean();
bean.setServers(casProperties.getTicket().getRegistry().getMemcached().getServers());
bean.setLocatorType(ConnectionFactoryBuilder.Locator.valueOf(casProperties.getTicket().getRegistry().getMemcached().getLocatorType()));
bean.setTranscoder(kryoTranscoder());
bean.setFailureMode(FailureMode.valueOf(casProperties.getTicket().getRegistry().getMemcached().getFailureMode()));
bean.setHashAlg(DefaultHashAlgorithm.valueOf(casProperties.getTicket().getRegistry().getMemcached().getHashAlgorithm()));
return bean;
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
use of net.spy.memcached.spring.MemcachedClientFactoryBean in project cas by apereo.
the class MemcachedPooledClientConnectionFactory method create.
@Override
@SneakyThrows
public MemcachedClientIF create() {
val factoryBean = new MemcachedClientFactoryBean();
factoryBean.setServers(memcachedProperties.getServers());
factoryBean.setTranscoder(this.transcoder);
if (StringUtils.isNotBlank(memcachedProperties.getLocatorType())) {
factoryBean.setLocatorType(ConnectionFactoryBuilder.Locator.valueOf(memcachedProperties.getLocatorType()));
}
if (StringUtils.isNotBlank(memcachedProperties.getFailureMode())) {
factoryBean.setFailureMode(FailureMode.valueOf(memcachedProperties.getFailureMode()));
}
if (StringUtils.isNotBlank(memcachedProperties.getHashAlgorithm())) {
factoryBean.setHashAlg(DefaultHashAlgorithm.valueOf(memcachedProperties.getHashAlgorithm()));
}
if (StringUtils.isNotBlank(memcachedProperties.getProtocol())) {
factoryBean.setProtocol(ConnectionFactoryBuilder.Protocol.valueOf(memcachedProperties.getProtocol()));
}
factoryBean.setDaemon(memcachedProperties.isDaemon());
factoryBean.setShouldOptimize(memcachedProperties.isShouldOptimize());
factoryBean.setUseNagleAlgorithm(memcachedProperties.isUseNagleAlgorithm());
if (memcachedProperties.getOpTimeout() > 0) {
factoryBean.setOpTimeout(memcachedProperties.getOpTimeout());
}
if (memcachedProperties.getMaxReconnectDelay() > 0) {
factoryBean.setMaxReconnectDelay(memcachedProperties.getMaxReconnectDelay());
}
if (memcachedProperties.getShutdownTimeoutSeconds() > 0) {
factoryBean.setShutdownTimeoutSeconds(memcachedProperties.getShutdownTimeoutSeconds());
}
if (memcachedProperties.getTimeoutExceptionThreshold() > 0) {
factoryBean.setTimeoutExceptionThreshold(memcachedProperties.getTimeoutExceptionThreshold());
}
factoryBean.afterPropertiesSet();
return (MemcachedClientIF) factoryBean.getObject();
}
Aggregations