Redis缓存空间优化实践详解(redis缓存优化)干货满满

随心笔谈2年前发布 编辑
141 0
🌐 经济型:买域名、轻量云服务器、用途:游戏 网站等 《腾讯云》特点:特价机便宜 适合初学者用 点我优惠购买
🚀 拓展型:买域名、轻量云服务器、用途:游戏 网站等 《阿里云》特点:中档服务器便宜 域名备案事多 点我优惠购买
🛡️ 稳定型:买域名、轻量云服务器、用途:游戏 网站等 《西部数码》 特点:比上两家略贵但是稳定性超好事也少 点我优惠购买

 public byte[] toByteArray() throws Exception {
MessageBufferPacker packer=MessagePack.newDefaultBufferPacker();
toByteArray(packer);
packer.close();
return packer.toByteArray();
}

public void toByteArray(MessageBufferPacker packer) throws Exception {
if (testStatus==null) {
packer.packNil();
}else{
packer.packString(testStatus);
}

if (userPin==null) {
packer.packNil();
}else{
packer.packString(userPin);
}

if (investor==null) {
packer.packNil();
}else{
packer.packString(investor);
}

if (testQueryTime==null) {
packer.packNil();
}else{
packer.packLong(testQueryTime.getTime());
}

if (createTime==null) {
packer.packNil();
}else{
packer.packLong(createTime.getTime());
}

if (bizInfo==null) {
packer.packNil();
}else{
packer.packString(bizInfo);
}

if (otherTime==null) {
packer.packNil();
}else{
packer.packLong(otherTime.getTime());
}

if (userAmount==null) {
packer.packNil();
}else{
packer.packString(userAmount.toString());
}

if (userRate==null) {
packer.packNil();
}else{
packer.packString(userRate.toString());
}

if (applyAmount==null) {
packer.packNil();
}else{
packer.packString(applyAmount.toString());
}

if (type==null) {
packer.packNil();
}else{
packer.packString(type);
}

if (checkTime==null) {
packer.packNil();
}else{
packer.packString(checkTime);
}

if (preTestStatus==null) {
packer.packNil();
}else{
packer.packString(preTestStatus);
}
}

public void fromByteArray(byte[] byteArray) throws Exception {
MessageUnpacker unpacker=MessagePack.newDefaultUnpacker(byteArray);
fromByteArray(unpacker);
unpacker.close();
}

public void fromByteArray(MessageUnpacker unpacker) throws Exception {
if (!unpacker.tryUnpackNil()){
this.setTestStatus(unpacker.unpackString());
}
if (!unpacker.tryUnpackNil()){
this.setUserPin(unpacker.unpackString());
}
if (!unpacker.tryUnpackNil()){
this.setInvestor(unpacker.unpackString());
}
if (!unpacker.tryUnpackNil()){
this.setTestQueryTime(new Date(unpacker.unpackLong()));
}
if (!unpacker.tryUnpackNil()){
this.setCreateTime(new Date(unpacker.unpackLong()));
}
if (!unpacker.tryUnpackNil()){
this.setBizInfo(unpacker.unpackString());
}
if (!unpacker.tryUnpackNil()){
this.setOtherTime(new Date(unpacker.unpackLong()));
}
if (!unpacker.tryUnpackNil()){
this.setUserAmount(new BigDecimal(unpacker.unpackString()));
}
if (!unpacker.tryUnpackNil()){
this.setUserRate(new BigDecimal(unpacker.unpackString()));
}
if (!unpacker.tryUnpackNil()){
this.setApplyAmount(new BigDecimal(unpacker.unpackString()));
}
if (!unpacker.tryUnpackNil()){
this.setType(unpacker.unpackString());
}
if (!unpacker.tryUnpackNil()){
this.setCheckTime(unpacker.unpackString());
}
if (!unpacker.tryUnpackNil()){
this.setPreTestStatus(unpacker.unpackString());
}
}

© 版权声明

相关文章