// Path: src/main/java/com/amebame/triton/config/TritonMemcachedClusterConfiguration.java
// public class TritonMemcachedClusterConfiguration {
// 	
// 	private String[] hosts;
// 	
// 	private TritonMemcachedLocator locator = TritonMemcachedLocator.simple;
// 
// 	public TritonMemcachedClusterConfiguration() {
// 	}
// 
// 	public String[] getHosts() {
// 		return hosts;
// 	}
// 	
// 	public void setHosts(String[] hosts) {
// 		this.hosts = hosts;
// 	}
// 	
// 	public void setHost(String host) {
// 		this.hosts = new String[] {host};
// 	}
// 	
// 	public TritonMemcachedLocator getLocator() {
// 		return locator;
// 	}
// 	
// 	public void setLocator(TritonMemcachedLocator locator) {
// 		this.locator = locator;
// 	}
// }
// 
// Path: src/main/java/com/amebame/triton/config/TritonMemcachedConfiguration.java
// public class TritonMemcachedConfiguration {
// 	
// 	private Map<String, TritonMemcachedClusterConfiguration> clusters;
// 
// 	public TritonMemcachedConfiguration() {
// 		clusters = new HashMap<>();
// 	}
// 	
// 	/**
// 	 * Get cluster map
// 	 * @return
// 	 */
// 	public Map<String, TritonMemcachedClusterConfiguration> getClusters() {
// 		return clusters;
// 	}
// 	
// 	/**
// 	 * Set cluster map
// 	 * @param clusters
// 	 */
// 	public void setClusters(Map<String, TritonMemcachedClusterConfiguration> clusters) {
// 		this.clusters = clusters;
// 	}
// 
// }
// 
// Path: src/main/java/com/amebame/triton/config/TritonMemcachedLocator.java
// public enum TritonMemcachedLocator {
// 
// 	simple,
// 	consistent_hash
// 	
// }
// 
// Path: src/main/java/com/amebame/triton/server/TritonCleaner.java
// public interface TritonCleaner {
// 	
// 	/**
// 	 * Clean the resource.
// 	 */
// 	void clean();
// 
// }


import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeoutException;
import javax.inject.Inject;
import net.rubyeye.xmemcached.HashAlgorithm;
import net.rubyeye.xmemcached.MemcachedClient;
import net.rubyeye.xmemcached.XMemcachedClientBuilder;
import net.rubyeye.xmemcached.command.BinaryCommandFactory;
import net.rubyeye.xmemcached.exception.MemcachedException;
import net.rubyeye.xmemcached.impl.KetamaMemcachedSessionLocator;
import net.rubyeye.xmemcached.utils.AddrUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.amebame.triton.config.TritonMemcachedClusterConfiguration;
import com.amebame.triton.config.TritonMemcachedConfiguration;
import com.amebame.triton.config.TritonMemcachedLocator;
import com.amebame.triton.exception.TritonErrors;
import com.amebame.triton.server.TritonCleaner;
import com.fasterxml.jackson.databind.JsonNode;
					TritonErrors.memcached_timeout,
					e);
		}
	}
	
	/**
	 * Delete key from cache
	 * @param cluster
	 * @param key
	 */
	public void delete(String cluster, String key) {
		MemcachedClient client = getClient(cluster);
		try {
			client.delete(key);
		} catch (MemcachedException | InterruptedException e) {
			throw new TritonMemcachedException(
					TritonErrors.memcached_error,
					e);
		} catch (TimeoutException e) {
			throw new TritonMemcachedException(
					TritonErrors.memcached_timeout,
					e);
		}
	}
	
	/**
	 * Create client from {@link TritonMemcachedClusterConfiguration}
	 * @param config
	 * @return
	 */
// Path: src/main/java/com/amebame/triton/config/TritonMemcachedClusterConfiguration.java
// public class TritonMemcachedClusterConfiguration {
// 	
// 	private String[] hosts;
// 	
// 	private TritonMemcachedLocator locator = TritonMemcachedLocator.simple;
// 
// 	public TritonMemcachedClusterConfiguration() {
// 	}
// 
// 	public String[] getHosts() {
// 		return hosts;
// 	}
// 	
// 	public void setHosts(String[] hosts) {
// 		this.hosts = hosts;
// 	}
// 	
// 	public void setHost(String host) {
// 		this.hosts = new String[] {host};
// 	}
// 	
// 	public TritonMemcachedLocator getLocator() {
// 		return locator;
// 	}
// 	
// 	public void setLocator(TritonMemcachedLocator locator) {
// 		this.locator = locator;
// 	}
// }
// 
// Path: src/main/java/com/amebame/triton/config/TritonMemcachedConfiguration.java
// public class TritonMemcachedConfiguration {
// 	
// 	private Map<String, TritonMemcachedClusterConfiguration> clusters;
// 
// 	public TritonMemcachedConfiguration() {
// 		clusters = new HashMap<>();
// 	}
// 	
// 	/**
// 	 * Get cluster map
// 	 * @return
// 	 */
// 	public Map<String, TritonMemcachedClusterConfiguration> getClusters() {
// 		return clusters;
// 	}
// 	
// 	/**
// 	 * Set cluster map
// 	 * @param clusters
// 	 */
// 	public void setClusters(Map<String, TritonMemcachedClusterConfiguration> clusters) {
// 		this.clusters = clusters;
// 	}
// 
// }
// 
// Path: src/main/java/com/amebame/triton/config/TritonMemcachedLocator.java
// public enum TritonMemcachedLocator {
// 
// 	simple,
// 	consistent_hash
// 	
// }
// 
// Path: src/main/java/com/amebame/triton/server/TritonCleaner.java
// public interface TritonCleaner {
// 	
// 	/**
// 	 * Clean the resource.
// 	 */
// 	void clean();
// 
// }


// Path: src/main/java/com/amebame/triton/service/memcached/TritonMemcachedClient.java
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeoutException;
import javax.inject.Inject;
import net.rubyeye.xmemcached.HashAlgorithm;
import net.rubyeye.xmemcached.MemcachedClient;
import net.rubyeye.xmemcached.XMemcachedClientBuilder;
import net.rubyeye.xmemcached.command.BinaryCommandFactory;
import net.rubyeye.xmemcached.exception.MemcachedException;
import net.rubyeye.xmemcached.impl.KetamaMemcachedSessionLocator;
import net.rubyeye.xmemcached.utils.AddrUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.amebame.triton.config.TritonMemcachedClusterConfiguration;
import com.amebame.triton.config.TritonMemcachedConfiguration;
import com.amebame.triton.config.TritonMemcachedLocator;
import com.amebame.triton.exception.TritonErrors;
import com.amebame.triton.server.TritonCleaner;
import com.fasterxml.jackson.databind.JsonNode;

					TritonErrors.memcached_timeout,
					e);
		}
	}
	
	/**
	 * Delete key from cache
	 * @param cluster
	 * @param key
	 */
	public void delete(String cluster, String key) {
		MemcachedClient client = getClient(cluster);
		try {
			client.delete(key);
		} catch (MemcachedException | InterruptedException e) {
			throw new TritonMemcachedException(
					TritonErrors.memcached_error,
					e);
		} catch (TimeoutException e) {
			throw new TritonMemcachedException(
					TritonErrors.memcached_timeout,
					e);
		}
	}
	
	/**
	 * Create client from {@link TritonMemcachedClusterConfiguration}
	 * @param config
	 * @return
	 */
	private MemcachedClient createClient(String name, TritonMemcachedClusterConfiguration config) throws IOException {