当前位置: IT大杂烩 > Ubuntu  > memcached

memcached

www.someabcd.com  网友分享于:Jun 8, 2018 5:50:49 PM

标签:

public class CacheUtils {

    private static MemCachedClient mcc = new MemCachedClient();

    private static CacheUtils utils = new CacheUtils();

    static {

        String[] servers = {"127.0.0.1:11211"};

        Integer[] weights = {3};

        SockIOPool pool = SockIOPool.getInstance();

        pool.setServers( servers );

        pool.setFailover( true );

        pool.setInitConn( 10 );

        pool.setMinConn( 5 );

        pool.setMaxConn( 250 );

        pool.setMaintSleep( 3000 );

        pool.setNagle( false );

        pool.setSocketTO( 3000 );

        pool.setAliveCheck( true );

        pool.initialize();

    }

    private CacheUtils() {    }

    public static CacheUtils getInstance() { return utils;    }

    public boolean add(String key, Object value) {

        return mcc.add(key, value);

    }

    public boolean add(String key, Object value, Date expiry) {

        return mcc.add(key, value, expiry);

    }

    public boolean replace(String key, Object value) {

        return mcc.replace(key, value);

    }

    public boolean replace(String key, Object value, Date expiry) {

        return mcc.replace(key, value, expiry);

    }

    public Object get(String key) {

        return mcc.get(key);

    }

}




memcached

标签:

发布此文章仅为传递网友分享,不代表本站观点,若侵权请联系我们删除,本站将不对此承担任何责任。
Copyright ©2018  IT大杂烩  版权所有  京ICP备11030978号-1 网站地图