Ejemplo n.º 1
0
        /// <summary>
        /// 异步发送Cache通知
        /// </summary>
        /// <param name="notifyDataArray">Cache通知数据</param>
        public void SendNotifyAsync(params CacheNotifyData[] notifyDataArray)
        {
            SendDataWrapper sdWrapper = new SendDataWrapper(
                notifyDataArray,
                GetSerializedCacheData(notifyDataArray),
                UdpCacheNotifierSettings.GetConfig().EndPoints);

            ThreadPool.QueueUserWorkItem(new WaitCallback(SendNotifyThreadCallBack), sdWrapper);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 发送Cache通知
        /// </summary>
        /// <param name="notifyDataArray">Cache通知数据</param>
        public void SendNotify(params CacheNotifyData[] notifyDataArray)
        {
            ExceptionHelper.FalseThrow <ArgumentNullException>(notifyDataArray != null, "notifyDataArray");

            UdpCacheNotifierSettings settings = UdpCacheNotifierSettings.GetConfig();

            List <byte[]> dataList = GetSerializedCacheData(notifyDataArray);

            SendSerializedData(notifyDataArray, dataList, settings.EndPoints);
        }
Ejemplo n.º 3
0
        private static List <byte[]> GetSerializedCacheData(CacheNotifyData[] notifyDataArray)
        {
            ExceptionHelper.FalseThrow <ArgumentNullException>(notifyDataArray != null, "notifyDataArray");

            UdpCacheNotifierSettings settings = UdpCacheNotifierSettings.GetConfig();

            List <byte[]> dataList = new List <byte[]>();

            foreach (CacheNotifyData notifyData in notifyDataArray)
            {
                byte[] data = notifyData.ToBytes();

                ExceptionHelper.FalseThrow(data.Length <= settings.PackageSize,
                                           "Cache Key{0}的通知数据包大小为{1}字节, 必须小于等于{2}字节,可以调整udpCacheNotifierSettings配置节的packageSize属性来解决此问题",
                                           notifyData.CacheKey, data.Length, settings.PackageSize);

                dataList.Add(data);
            }

            return(dataList);
        }