memcached 不同客户端存取值问题
本人接触memcached不多,希望下面的问题能帮助到遇到同样问题的同学,作为个人日记记录一下。
昨天调试memcached发现,在手机端存进去的值,java端没取到。
一般我们只关注key和value,发现并无问题;然后好好看了下flags。
查源码发现cmd = cmdname + " " + key + " " + flags + " " + expiry.getTime() / 1000L + " ";
flags = NativeHandler.getMarkerFlag(value);继续看源码:
public static final int getMarkerFlag(Object value)
{
if(value instanceof Byte)
return 1;
if(value instanceof Boolean)
return 8192;
if(value instanceof Integer)
return 4;
if(value instanceof Long)
return 16384;
if(value instanceof Character)
return 16;
if(value instanceof String)
return 32;
if(value instanceof StringBuffer)
return 64;
if(value instanceof Float)
return 128;
if(value instanceof Short)
return 256;
if(value instanceof Double)
return 512;
if(value instanceof Date)
return 1024;
if(value instanceof StringBuilder)
return 2048;
return !(value instanceof byte[]) ? 0 : 4096;
}终于明白了,javastring类型存储默认flags=32。
修正setflags再测试,问题解决。
相关推荐
qingmoucsdn 2019-11-17
ThinkingLink 2019-10-30
ThinkingLink 2019-10-23
linglongbayinhe 2016-11-17
gavinvong 2019-07-01
pdw00 2019-07-01
JavaJspSsh 2019-07-01
西门吹雪 2019-07-01
fuziwang 2019-06-29
jacklife 2013-06-28
xxjoy 2019-06-28
gjcxywwx 2019-06-28
yhunii 2019-06-28
DolphinThinker 2019-06-28
Phplayers 2019-06-28
js网页特效 2019-06-28
Eric实验室 2019-06-28
zzrshuiwuhen 2019-06-28
王甲评 2019-06-28