nullITeye - 牛牛娱乐

nullITeye

2019年03月06日13时30分11秒 | 作者: 雁蓉 | 标签: | 浏览: 1808

MemcachedClientBuilder builder = new XMemcachedClientBuilder( AddrUtil.getAddresses("192.168.204.201:11211"), new int[] { 3 }); builder.setFailureMode(true); // 运用二进制文件 builder.setCommandFactory(new BinaryCommandFactory()); builder.setConnectionPoolSize(10); builder.setSocketOption(StandardSocketOption.SO_RCVBUF, 32 * 1024); // 设置接纳缓存区为32K,默许16K builder.setSocketOption(StandardSocketOption.SO_SNDBUF, 16 * 1024); // 设置发送缓冲区为16K,默许为8K builder.setSocketOption(StandardSocketOption.TCP_NODELAY, false); // 启用nagle算法,进步吞吐量,默许封闭 builder.setOpTimeout(10000);// 设置超时为10秒 cachedClient = builder.build(); } catch (Exception e) { // TODO: handle exception * @throws MemcachedException * @throws InterruptedException * @throws TimeoutException * @Title: add * @Description: 增加一个值,假如现已存在,则回来false * @param key 键 * @param value 值 * @return * @throws public static boolean add(String key, Object value) throws TimeoutException, InterruptedException, MemcachedException { return cachedClient.add(key, 0, value); * @throws MemcachedException * @throws InterruptedException * @throws TimeoutException * @Title: add * @Description: 增加一个值,假如现已存在,则回来false * @param key 键 * @param value 值 * @param expire 存活期 * @return * @throws public static boolean add(String key, Object value, Integer expire) throws TimeoutException, InterruptedException, MemcachedException { return cachedClient.add(key, expire, value); * @throws MemcachedException * @throws InterruptedException * @throws TimeoutException * @Title: put * @Description: 向Memcache增加一个值,假如现已存在,则覆写 * @param key 键 * @param value 值 * @return * @throws public static boolean put(String key, Object value) throws TimeoutException, InterruptedException, MemcachedException { return cachedClient.set(key, 0, value); * @throws MemcachedException * @throws InterruptedException * @throws TimeoutException * @Title: put * @Description: 向Memcache增加一个值,假如现已存在,则覆写 * @param key 键 * @param value 值 * @param expire 存活期 * @return * @throws public static boolean put(String key, Object value, Integer expire) throws TimeoutException, InterruptedException, MemcachedException { return cachedClient.set(key, expire, value); * @throws MemcachedException * @throws InterruptedException * @throws TimeoutException * @Title: replace * @Description: 替换一个现已存在Memcache服务器上的项目 * @param key 键 * @param value 值 * @return * @throws public static boolean replace(String key, Object value) throws TimeoutException, InterruptedException, MemcachedException { return cachedClient.replace(key, 0, value); * @throws MemcachedException * @throws InterruptedException * @throws TimeoutException * @Title: replace * @Description: 替换一个现已存在Memcache服务器上的项目 * @param key 键 * @param value 值 * @param expire 存活期 * @return * @throws public static boolean replace(String key, Object value, Integer expire) throws TimeoutException, InterruptedException, MemcachedException { return cachedClient.replace(key, expire, value); * @throws MemcachedException * @throws InterruptedException * @throws TimeoutException * @Title: get * @Description: 从Memcache上获取一个key值 * @param key 键 * @return * @throws public static Object get(String key) throws TimeoutException, InterruptedException, MemcachedException { return cachedClient.get(key); * @throws MemcachedException * @throws InterruptedException * @throws TimeoutException * @Title: delete * @Description: 删去一个Memcache上的key值 * @param key 键 * @return * @throws public static boolean delete(String key) throws TimeoutException, InterruptedException, MemcachedException { return cachedClient.delete(key);

 

版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表牛牛娱乐立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章

阅读排行

  • 1
  • 2

    UTLITeye

    数据,目录,文件
  • 3
  • 4
  • 5

    java与函数式编程ITeye

    函数,编程,一些
  • 6
  • 7
  • 8
  • 9
  • 10