首页

通过xmemcached包定义MemcachedUtils缓存工具类进行对memcached缓存进行处理代码示例

标签:xmemcached,MemcachedUtils,缓存工具类     发布时间:2018-10-11   

一、前言

通过xmemcached包的net.rubyeye.xmemcached.MemcachedClient客户端缓存类定义MemcachedUtils工具类,对memcached缓存进行连接处理,详情代码示例及相关配置。

二、代码示例

1. MemcachedUtils工具类

package com.xwood.framework.core.base.util; @b@@b@import java.io.IOException;@b@import java.net.InetSocketAddress;@b@import java.util.Collection;@b@import java.util.List;@b@import java.util.Map;@b@import java.util.Queue;@b@import java.util.concurrent.TimeoutException; @b@import net.rubyeye.xmemcached.CASOperation;@b@import net.rubyeye.xmemcached.Counter;@b@import net.rubyeye.xmemcached.GetsResponse;@b@import net.rubyeye.xmemcached.KeyIterator;@b@import net.rubyeye.xmemcached.MemcachedClient;@b@import net.rubyeye.xmemcached.MemcachedClientStateListener;@b@import net.rubyeye.xmemcached.auth.AuthInfo;@b@import net.rubyeye.xmemcached.buffer.BufferAllocator;@b@import net.rubyeye.xmemcached.exception.MemcachedException;@b@import net.rubyeye.xmemcached.impl.ReconnectRequest;@b@import net.rubyeye.xmemcached.networking.Connector;@b@import net.rubyeye.xmemcached.transcoders.Transcoder;@b@import net.rubyeye.xmemcached.utils.Protocol;@b@@b@ @b@public class MemcachedUtils {@b@@b@    private MemcachedClient memcachedClient;@b@@b@    private static MemcachedUtils memcachedUtils;@b@@b@    public void setMemcachedClient(MemcachedClient memcachedClient) {@b@        this.memcachedClient = memcachedClient;@b@    }@b@@b@    public void init() {@b@        memcachedUtils = this;@b@        memcachedUtils.memcachedClient = this.memcachedClient;@b@    }@b@@b@    public static void setMergeFactor(int mergeFactor) {@b@        memcachedUtils.memcachedClient.setMergeFactor(mergeFactor);@b@    }@b@@b@    public static String getName() {@b@        return memcachedUtils.memcachedClient.getName();@b@    }@b@@b@    public static void setName(String name) {@b@        memcachedUtils.memcachedClient.setName(name);@b@    }@b@@b@    public static long getConnectTimeout() {@b@        return memcachedUtils.memcachedClient.getConnectTimeout();@b@    }@b@@b@    public static void setConnectTimeout(long connectTimeout) {@b@        memcachedUtils.memcachedClient.setConnectTimeout(connectTimeout);@b@    }@b@@b@    public static void setEnableHeartBeat(boolean enableHeartBeat) {@b@        memcachedUtils.memcachedClient.setEnableHeartBeat(enableHeartBeat);@b@    }@b@@b@    public static long getOpTimeout() {@b@        return memcachedUtils.memcachedClient.getOpTimeout();@b@    }@b@@b@    public static void setOpTimeout(long opTimeout) {@b@        memcachedUtils.memcachedClient.setOpTimeout(opTimeout);@b@    }@b@@b@    public static void setHealSessionInterval(long healConnectionInterval) {@b@        memcachedUtils.memcachedClient.setHealSessionInterval(healConnectionInterval);@b@    }@b@@b@    public static long getHealSessionInterval() {@b@        return memcachedUtils.memcachedClient.getHealSessionInterval();@b@    }@b@@b@    public static Map<InetSocketAddress, AuthInfo> getAuthInfoMap() {@b@        return memcachedUtils.memcachedClient.getAuthInfoMap();@b@    }@b@@b@    public static void setAuthInfoMap(Map<InetSocketAddress, AuthInfo> map) {@b@        memcachedUtils.memcachedClient.setAuthInfoMap(map);@b@    }@b@@b@    public static Connector getConnector() {@b@        return memcachedUtils.memcachedClient.getConnector();@b@    }@b@@b@    public static void setOptimizeMergeBuffer(boolean optimizeMergeBuffer) {@b@        memcachedUtils.memcachedClient.setOptimizeMergeBuffer(optimizeMergeBuffer);@b@    }@b@@b@    public static boolean isShutdown() {@b@        return memcachedUtils.memcachedClient.isShutdown();@b@    }@b@@b@    public static void addServer(String server, int port) throws IOException {@b@        memcachedUtils.memcachedClient.addServer(server, port);@b@    }@b@@b@    public static void addServer(String server, int port, int weight) throws IOException {@b@        memcachedUtils.memcachedClient.addServer(server, port, weight);@b@    }@b@@b@    public static void addServer(InetSocketAddress inetSocketAddress) throws IOException {@b@        memcachedUtils.memcachedClient.addServer(inetSocketAddress);@b@    }@b@@b@    public static void addServer(InetSocketAddress inetSocketAddress, int weight) throws IOException {@b@        memcachedUtils.memcachedClient.addServer(inetSocketAddress, weight);@b@    }@b@@b@    public static void addServer(String hostList) throws IOException {@b@        memcachedUtils.memcachedClient.addServer(hostList);@b@    }@b@@b@    public static List<String> getServersDescription() {@b@        return memcachedUtils.memcachedClient.getServersDescription();@b@    }@b@@b@    public static void removeServer(String hostList) {@b@        memcachedUtils.memcachedClient.removeServer(hostList);@b@    }@b@@b@    public static void setOptimizeGet(boolean optimizeGet) {@b@        memcachedUtils.memcachedClient.setOptimizeGet(optimizeGet);@b@@b@    }@b@@b@    public static void setBufferAllocator(BufferAllocator bufferAllocator) {@b@        memcachedUtils.memcachedClient.setBufferAllocator(bufferAllocator);@b@    }@b@@b@    public static <T> T get(String key, long timeout, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.get(key, timeout, transcoder);@b@    }@b@@b@    public static <T> T get(String key, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return (T) memcachedUtils.memcachedClient.get(key, timeout);@b@    }@b@@b@    public static <T> T get(String key, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.get(key, transcoder);@b@    }@b@@b@    public static <T> T get(String key) throws TimeoutException, InterruptedException, MemcachedException {@b@        return (T) memcachedUtils.memcachedClient.get(key);@b@    }@b@@b@    public static <T> GetsResponse<T> gets(String key, long timeout, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.gets(key, timeout, transcoder);@b@    }@b@@b@    public static <T> GetsResponse<T> gets(String key) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.gets(key);@b@    }@b@@b@    public static <T> GetsResponse<T> gets(String key, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.gets(key, timeout);@b@    }@b@@b@    public static <T> GetsResponse<T> gets(String key, Transcoder transcoder) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.gets(key, transcoder);@b@    }@b@@b@    public static <T> Map<String, T> get(Collection<String> keyCollections) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.get(keyCollections);@b@    }@b@@b@    public static <T> Map<String, T> get(Collection<String> keyCollections, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.get(keyCollections, timeout);@b@    }@b@@b@    public static <T> Map<String, GetsResponse<T>> gets(Collection<String> keyCollections) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.gets(keyCollections);@b@    }@b@@b@    public static <T> Map<String, GetsResponse<T>> gets(Collection<String> keyCollections, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.gets(keyCollections, timeout);@b@    }@b@@b@    public static <T> boolean set(String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.set(key, exp, value, transcoder, timeout);@b@    }@b@@b@    public static void setWithNoReply(String key, int exp, Object value) throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.setWithNoReply(key, exp, value);@b@    }@b@@b@    public static <T> void setWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.setWithNoReply(key, exp, value, transcoder);@b@    }@b@@b@    public static boolean set(String key, int exp, Object value) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.set(key, exp, value);@b@    }@b@@b@    public static boolean set(String key, int exp, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.set(key, exp, value, timeout);@b@    }@b@@b@    public static <T> boolean set(String key, int exp, T value, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.set(key, exp, value, transcoder);@b@    }@b@@b@    public static <T> boolean add(String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.add(key, exp, value, transcoder, timeout);@b@    }@b@@b@    public static boolean add(String key, int exp, Object value) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.add(key, exp, value);@b@    }@b@@b@    public static boolean add(String key, int exp, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.add(key, exp, value, timeout);@b@    }@b@@b@    public static <T> boolean add(String key, int exp, T value, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.add(key, exp, value, transcoder);@b@    }@b@@b@    public static void addWithNoReply(String key, int exp, Object value) throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.addWithNoReply(key, exp, value);@b@    }@b@@b@    public static <T> void addWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.addWithNoReply(key, exp, value, transcoder);@b@    }@b@@b@    public static void replaceWithNoReply(String key, int exp, Object value) throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.replaceWithNoReply(key, exp, value);@b@    }@b@@b@    public static <T> void replaceWithNoReply(String key, int exp, T value, Transcoder<T> transcoder) throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.replaceWithNoReply(key, exp, value, transcoder);@b@    }@b@@b@    public static <T> boolean replace(String key, int exp, T value, Transcoder<T> transcoder, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.replace(key, exp, value, transcoder, timeout);@b@    }@b@@b@    public static boolean replace(String key, int exp, Object value) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.replace(key, exp, value);@b@    }@b@@b@    public static boolean replace(String key, int exp, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.replace(key, exp, value);@b@    }@b@@b@    public static <T> boolean replace(String key, int exp, T value, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.replace(key, exp, value, transcoder);@b@    }@b@@b@    public static boolean append(String key, Object value) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.append(key, value);@b@    }@b@@b@    public static boolean append(String key, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.append(key, value, timeout);@b@    }@b@@b@    public static void appendWithNoReply(String key, Object value) throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.appendWithNoReply(key, value);@b@    }@b@@b@    public static boolean prepend(String key, Object value) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.prepend(key, value);@b@    }@b@@b@    public static boolean prepend(String key, Object value, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.prepend(key, value, timeout);@b@    }@b@@b@    public static void prependWithNoReply(String key, Object value) throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.prependWithNoReply(key, value);@b@    }@b@@b@    public static boolean cas(String key, int exp, Object value, long cas) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.cas(key, exp, value, cas);@b@    }@b@@b@    public static <T> boolean cas(String key, int exp, T value, Transcoder<T> transcoder, long timeout, long cas) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.cas(key, exp, value, transcoder, timeout, cas);@b@    }@b@@b@    public static boolean cas(String key, int exp, Object value, long timeout, long cas) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.cas(key, exp, value, timeout, cas);@b@    }@b@@b@    public static <T> boolean cas(String key, int exp, T value, Transcoder<T> transcoder, long cas) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.cas(key, exp, value, transcoder, cas);@b@    }@b@@b@    public static <T> boolean cas(String key, int exp, CASOperation<T> operation, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.cas(key, exp, operation, transcoder);@b@    }@b@@b@    public static <T> boolean cas(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.cas(key, exp, getsReponse, operation, transcoder);@b@    }@b@@b@    public static <T> boolean cas(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.cas(key, exp, getsReponse, operation);@b@    }@b@@b@    public static <T> void casWithNoReply(String key, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.casWithNoReply(key, operation);@b@    }@b@@b@    public static <T> void casWithNoReply(String key, GetsResponse<T> getsResponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.casWithNoReply(key, getsResponse, operation);@b@    }@b@@b@    public static <T> void casWithNoReply(String key, int exp, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.casWithNoReply(key, exp, operation);@b@    }@b@@b@    public static <T> void casWithNoReply(String key, int exp, GetsResponse<T> getsReponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.cas(key, exp, getsReponse, operation);@b@    }@b@@b@    public static <T> boolean cas(String key, GetsResponse<T> getsReponse, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.cas(key, getsReponse, operation);@b@    }@b@@b@    public static <T> boolean cas(String key, int exp, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.cas(key, exp, operation);@b@    }@b@@b@    public static <T> boolean cas(String key, CASOperation<T> operation) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.cas(key, operation);@b@    }@b@@b@    public static boolean delete(String key, int time) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.delete(key, time);@b@    }@b@@b@    public static boolean delete(String key, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.delete(key, opTimeout);@b@    }@b@@b@    public static void deleteWithNoReply(String key, int time) throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.deleteWithNoReply(key, time);@b@    }@b@@b@    public static void deleteWithNoReply(String key) throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.deleteWithNoReply(key);@b@    }@b@@b@    public static boolean touch(String key, int exp, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.touch(key, exp, opTimeout);@b@    }@b@@b@    public static boolean touch(String key, int exp) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.touch(key, exp);@b@    }@b@@b@    public static <T> T getAndTouch(String key, int newExp, long opTimeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return (T) memcachedUtils.memcachedClient.getAndTouch(key, newExp, opTimeout);@b@    }@b@@b@    public static <T> T getAndTouch(String key, int newExp) throws TimeoutException, InterruptedException, MemcachedException {@b@        return (T) memcachedUtils.memcachedClient.getAndTouch(key, newExp);@b@    }@b@@b@    public static long incr(String key, long delta) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.incr(key, delta);@b@    }@b@@b@    public static long incr(String key, long delta, long initValue) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.incr(key, delta, initValue);@b@    }@b@@b@    public static long incr(String key, long delta, long initValue, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.incr(key, delta, initValue, timeout);@b@    }@b@@b@    public static long incr(String key, long delta, long initValue, long timeout, int exp) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.incr(key, delta, initValue, timeout, exp);@b@    }@b@@b@    public static void incrWithNoReply(String key, long delta) throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.incrWithNoReply(key, delta);@b@    }@b@@b@    public static void decrWithNoReply(String key, long delta) throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.decrWithNoReply(key, delta);@b@    }@b@@b@    public static long decr(String key, long delta) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.decr(key, delta);@b@    }@b@@b@    public static long decr(String key, long delta, long initValue) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.decr(key, delta, initValue);@b@    }@b@@b@    public static long decr(String key, long delta, long initValue, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.decr(key, delta, initValue, timeout);@b@    }@b@@b@    public static long decr(String key, long delta, long initValue, long timeout, int exp) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.decr(key, delta, initValue, timeout, exp);@b@    }@b@@b@    public static void flushAll() throws TimeoutException, InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.flushAll();@b@    }@b@@b@    public static void flushAllWithNoReply() throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.flushAllWithNoReply();@b@    }@b@@b@    public static void flushAllWithNoReply(int exptime) throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.flushAllWithNoReply(exptime);@b@    }@b@@b@    public static void flushAllWithNoReply(InetSocketAddress address) throws MemcachedException, InterruptedException {@b@        memcachedUtils.memcachedClient.flushAllWithNoReply(address);@b@    }@b@@b@    public static void flushAllWithNoReply(InetSocketAddress address, int exptime) throws MemcachedException, InterruptedException {@b@        memcachedUtils.memcachedClient.flushAllWithNoReply(address, exptime);@b@    }@b@@b@    public static void flushAll(int exptime, long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.flushAll(exptime, timeout);@b@    }@b@@b@    public static void flushAll(long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.flushAll(timeout);@b@    }@b@@b@    public static void setLoggingLevelVerbosity(InetSocketAddress address, int level) throws TimeoutException, InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.setLoggingLevelVerbosity(address, level);@b@    }@b@@b@    public static void setLoggingLevelVerbosityWithNoReply(InetSocketAddress address, int level) throws InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.setLoggingLevelVerbosityWithNoReply(address, level);@b@    }@b@@b@    public static void flushAll(InetSocketAddress address) throws MemcachedException, InterruptedException, TimeoutException {@b@        memcachedUtils.memcachedClient.flushAll(address);@b@    }@b@@b@    public static void flushAll(InetSocketAddress address, long timeout) throws MemcachedException, InterruptedException, TimeoutException {@b@        memcachedUtils.memcachedClient.flushAll(address, timeout);@b@    }@b@@b@    public static void flushAll(InetSocketAddress address, long timeout, int exptime) throws MemcachedException, InterruptedException, TimeoutException {@b@        memcachedUtils.memcachedClient.flushAll(address, timeout, exptime);@b@    }@b@@b@    public static void flushAll(String host) throws TimeoutException, InterruptedException, MemcachedException {@b@        memcachedUtils.memcachedClient.flushAll(host);@b@    }@b@@b@    public static Map<String, String> stats(InetSocketAddress address) throws MemcachedException, InterruptedException, TimeoutException {@b@        return memcachedUtils.memcachedClient.stats(address);@b@    }@b@@b@    public static Map<String, String> stats(InetSocketAddress address, long timeout) throws MemcachedException, InterruptedException, TimeoutException {@b@        return memcachedUtils.memcachedClient.stats(address, timeout);@b@    }@b@@b@    public static Map<InetSocketAddress, Map<String, String>> getStats() throws MemcachedException, InterruptedException, TimeoutException {@b@        return memcachedUtils.memcachedClient.getStats();@b@    }@b@@b@    public static Map<InetSocketAddress, Map<String, String>> getStatsByItem(String itemName) throws MemcachedException, InterruptedException, TimeoutException {@b@        return memcachedUtils.memcachedClient.getStatsByItem(itemName);@b@    }@b@@b@    public static Map<InetSocketAddress, Map<String, String>> getStatsByItem(String itemName, long timeout) throws MemcachedException, InterruptedException, TimeoutException {@b@        return memcachedUtils.memcachedClient.getStatsByItem(itemName, timeout);@b@    }@b@@b@    public static Map<InetSocketAddress, String> getVersions() throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.getVersions();@b@    }@b@@b@    public static Map<InetSocketAddress, String> getVersions(long timeout) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.getVersions(timeout);@b@    }@b@@b@    public static Map<InetSocketAddress, Map<String, String>> getStats(long timeout) throws MemcachedException, InterruptedException, TimeoutException {@b@        return memcachedUtils.memcachedClient.getStats(timeout);@b@    }@b@@b@    public static void shutdown() throws IOException {@b@        memcachedUtils.memcachedClient.shutdown();@b@    }@b@@b@    public static void setConnectionPoolSize(int poolSize) {@b@        memcachedUtils.memcachedClient.setConnectionPoolSize(poolSize);@b@    }@b@@b@    public static boolean delete(String key) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.delete(key);@b@    }@b@@b@    public static Transcoder getTranscoder() {@b@        return memcachedUtils.memcachedClient.getTranscoder();@b@    }@b@@b@    public static void setTranscoder(Transcoder transcoder) {@b@        memcachedUtils.memcachedClient.setTranscoder(transcoder);@b@    }@b@@b@    public static Collection<InetSocketAddress> getAvaliableServers() {@b@        return memcachedUtils.memcachedClient.getAvaliableServers();@b@    }@b@@b@    public static void addStateListener(MemcachedClientStateListener listener) {@b@        memcachedUtils.memcachedClient.addStateListener(listener);@b@    }@b@@b@    public static Collection<MemcachedClientStateListener> getStateListeners() {@b@        return memcachedUtils.memcachedClient.getStateListeners();@b@    }@b@@b@    public static void setPrimitiveAsString(boolean primitiveAsString) {@b@        memcachedUtils.memcachedClient.setPrimitiveAsString(primitiveAsString);@b@    }@b@@b@    public static void removeStateListener(MemcachedClientStateListener listener) {@b@        memcachedUtils.memcachedClient.removeStateListener(listener);@b@    }@b@@b@    public static Protocol getProtocol() {@b@        return memcachedUtils.memcachedClient.getProtocol();@b@    }@b@@b@    public static boolean isSanitizeKeys() {@b@        return memcachedUtils.memcachedClient.isSanitizeKeys();@b@    }@b@@b@    public static void setSanitizeKeys(boolean sanitizeKeys) {@b@        memcachedUtils.memcachedClient.setSanitizeKeys(sanitizeKeys);@b@    }@b@@b@    public static Counter getCounter(String key, long initialValue) {@b@        return memcachedUtils.memcachedClient.getCounter(key, initialValue);@b@    }@b@@b@    public static Counter getCounter(String key) {@b@        return memcachedUtils.memcachedClient.getCounter(key);@b@    }@b@@b@    /** @deprecated */@b@    public static KeyIterator getKeyIterator(InetSocketAddress address) throws MemcachedException, TimeoutException, InterruptedException {@b@        return memcachedUtils.memcachedClient.getKeyIterator(address);@b@    }@b@@b@    public static void setFailureMode(boolean failureMode) {@b@        memcachedUtils.memcachedClient.setFailureMode(failureMode);@b@    }@b@@b@    public static boolean isFailureMode() {@b@        return memcachedUtils.memcachedClient.isFailureMode();@b@    }@b@@b@    public static Queue<ReconnectRequest> getReconnectRequestQueue() {@b@        return memcachedUtils.memcachedClient.getReconnectRequestQueue();@b@    }@b@@b@    public static <T> Map<String, T> get(Collection<String> keyCollections, long timeout, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.get(keyCollections, timeout, transcoder);@b@    }@b@@b@    public static <T> Map<String, T> get(Collection<String> keyCollections, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.get(keyCollections, transcoder);@b@    }@b@@b@    public static <T> Map<String, GetsResponse<T>> gets(Collection<String> keyCollections, long timeout, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.gets(keyCollections, timeout, transcoder);@b@    }@b@@b@    public static <T> Map<String, GetsResponse<T>> gets(Collection<String> keyCollections, Transcoder<T> transcoder) throws TimeoutException, InterruptedException, MemcachedException {@b@        return memcachedUtils.memcachedClient.gets(keyCollections, transcoder);@b@    }@b@}

2.  applicationContext-memcached.xml配置

<?xml version="1.0" encoding="UTF-8"?>@b@<beans xmlns="http://www.springframework.org/schema/beans"@b@	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"@b@	xsi:schemaLocation="@b@            http://www.springframework.org/schema/beans@b@            http://www.springframework.org/schema/beans/spring-beans.xsd">@b@            @b@	<!-- XMemcached -->@b@@b@	<bean name="memcachedClient"@b@		class="net.rubyeye.xmemcached.utils.XMemcachedClientFactoryBean"@b@		destroy-method="shutdown">@b@		<property name="servers">@b@			<value>localhost:11211</value>@b@		</property>@b@	</bean>@b@@b@	<!-- Memcached Utils -->@b@	<bean id="memcachedUtils" class="com.xwood.framework.core.base.util.MemcachedUtils"@b@		init-method="init">@b@		<property name="memcachedClient" ref="memcachedClient" />@b@	</bean>@b@	@b@</beans>