func (this *CacheComponent2) Dispatch2(msg *protocol.Message, flag bool) {
	cached := uint16(1 << 15)
	if (msg.Number & cached) != cached {
		return
	}
	msg.Number &= HEAD_RESET

	msg, err := this.MakeCacheMessage(msg)
	if err != nil {
		fmt.Println("CacheCompoennt Dispatch2 Error:" + err.Error())
		return
	}
	data1, err := msg.Encode()
	if err != nil {
		fmt.Println("CacheCompoennt Dispatch2 Error:", err)
		return
	}
	data2 := make([]byte, len(data1)+8)
	copy(data2[:8], msg.Data[0:8])
	copy(data2[8:], data1)

	snode_component.GetNodeComponent().Forward(stree_define.ADD_CACHE_ENTRY, msg.DestUuid, msg.DeviceId, data2)
	//if this message is a contact sync message, send it to root first.
	if (msg.Number == protocol.N_ACCOUNT_SYS || msg.DeviceId == 0) && flag {
		snode_component.GetNodeComponent().Forward(stree_define.BROADCAST_TO_CLIENT, msg.DestUuid, msg.DeviceId, data1)
	} else {
		GetDispatcherOutComponent().NPushBack(msg, flag)
	}
	return
}
func (this *CacheComponent) Save(msg protocol.Message) error {
	this.CacheLock.Lock()
	defer this.CacheLock.Unlock()
	if this.Cache == nil {
		this.Cache = make(map[string]CacheDev, 0)
	}

	if _, ok := this.Cache[msg.DestUuid]; !ok {
		val := CacheDev{
			MDev: make(map[uint32]*CacheList, 0),
		}
		this.Cache[msg.DestUuid] = val
	}

	if _, ok := this.Cache[msg.DestUuid].MDev[msg.DeviceId]; !ok {
		val := &CacheList{
			List:  list.New(),
			Total: 0,
		}
		this.Cache[msg.DestUuid].MDev[msg.DeviceId] = val
	}

	this.Cache[msg.DestUuid].MDev[msg.DeviceId].Total++
	id := this.Cache[msg.DestUuid].MDev[msg.DeviceId].Total
	msg.DataLen = 4 + msg.DataLen
	buf := make([]byte, msg.DataLen)
	binary.BigEndian.PutUint32(buf[0:4], id)
	if len(msg.Data) > 0 {
		copy(buf[4:msg.DataLen], msg.Data)
	}
	msg.Data = buf

	msg.MsgType = protocol.MT_PUSH_WITH_RESPONSE
	msg.PushType = protocol.PT_PUSHSERVER
	msg.Number &= HEAD_RESET

	e := this.Cache[msg.DestUuid].MDev[msg.DeviceId].List.PushBack(CacheEntry{msg, id})
	if e == nil {
		err := errors.New("CacheComponent.Save() Error: can not save msg to list")
		fmt.Println(err.Error())
		return err
	}

	return nil
}