java报错pool_Memcached+Java报错

Memcached+Java报错

关注:232  答案:1  mip版

解决时间 2021-02-05 00:15

e6cb1a03ad541b3098697807b7bf1798.png

提问者终不敌时光

2021-02-04 16:35

public class Test {

private static final String POOL_NAME="mysql";

protected static MemCachedClient mcc;

static {

//设置缓存服务器列表,当使用分布式缓存的时,可以指定多个缓存服务器

String[] servers =

{

"127.0.0.1:3306"

};

//与服务器列表中对应的各服务器的权重

Integer[] weights = {3};

//创建Socked连接池

SockIOPool pool = SockIOPool.getInstance(POOL_NAME);

//向连接池设定服务器和权重

pool.setServers( servers );

pool.setWeights( weights );

//连接池参数

pool.setInitConn( 5 );

pool.setMinConn( 5 );

pool.setMaxConn( 250 );

pool.setMaxIdle( 1000 * 60 * 60 * 6 );

// set the sleep for the maint thread

// it will wake up every x seconds and

// maintain the pool size

pool.setMaintSleep( 30 );

// set some TCP settings

// disable nagle

// set the read timeout to 3 secs

// and don't set a connect timeout

pool.setNagle( false );

pool.setSocketTO( 3000 );

pool.setSocketConnectTO( 0 );

// initialize the connection pool

pool.initialize();

// lets set some compression on for the client

// compress anything larger than 64k

mcc=new MemCachedClient(POOL_NAME);

mcc.setCompressEnable( true );

mcc.setCompressThreshold( 64 * 1024 );

}

public static void main(String[] args) throws Exception{

mcc.set("msg","Hello,world!",new Date(System.currentTimeMillis()+1300));

Thread.sleep(500);

System.out.println(mcc.get("msg"));

}

}

异常:

Exception in thread "main" java.lang.ExceptionInInitializerError

Caused by: java.lang.UnsupportedOperationException

at com.danga.MemCached.MemCachedClient.setCompressEnable(Unknown Source)

at spring.unif.tool.Test.(Test.java:46)

最佳答案

e6cb1a03ad541b3098697807b7bf1798.png

二级知识专家千里故人稀

2021-02-04 17:18

正好 我刚做了一个 要源码吗?

我要举报

如以上问答内容为低俗/色情/暴力/不良/侵权的信息,可以点下面链接进行举报,我们会做出相应处理,感谢你的支持!

→点此我要举报以上信息!←

推荐资讯

大家都在看

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值