Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="dataList"></param>
 /// <param name="sendParam"></param>
 public void SendData <T>(T[] dataList, TransSendParam sendParam) where T : AbstractEntity, new()
 {
     using (IDataSender sender = new RedisDataSender())
     {
         sender.Send(dataList, sendParam.IsChange, sendParam.ConnectKey, sendParam.BeforeProcessHandle);
     }
 }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="dataList"></param>
 /// <param name="sendParam"></param>
 public void SendData <T>(T[] dataList, TransSendParam sendParam) where T : AbstractEntity, new()
 {
     using (IDataSender sender = new RedisDataSender())
     {
         sender.Send(dataList);
     }
 }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="dataList"></param>
 /// <param name="sendParam"></param>
 public bool SendData <T>(T[] dataList, TransSendParam sendParam) where T : AbstractEntity, new()
 {
     using (IDataSender sender = new RedisDataSender(sendParam))
     {
         return(sender.Send(dataList));
     }
 }
Пример #4
0
            private void OnSync(object state)
            {
                try
                {
                    if (Monitor.TryEnter(syncObject, 1000))
                    {
                        try
                        {
                            var list = CacheChangeManager.Current.GetKeys(0, 100);
                            foreach (var pair in list)
                            {
                                string key = pair.Key;
                                try
                                {
                                    CacheItemSet itemSet;
                                    CacheType    cacheType = CacheType.None;
                                    dynamic      entity    = CacheFactory.GetPersonalEntity(key, out itemSet);
                                    if (itemSet != null)
                                    {
                                        cacheType = itemSet.ItemType;
                                    }
                                    if (entity == null)
                                    {
                                        entity = CovertEntityObject(key, pair.Value);
                                        if (entity != null)
                                        {
                                            SchemaTable schema;
                                            Type        entityType = entity.GetType();
                                            if (!EntitySchemaSet.TryGet(entityType, out schema))
                                            {
                                                EntitySchemaSet.InitSchema(entityType);
                                            }
                                            if (schema != null || EntitySchemaSet.TryGet(entityType, out schema))
                                            {
                                                cacheType = schema.CacheType;
                                            }
                                        }
                                    }
                                    if (entity != null && cacheType != CacheType.None)
                                    {
                                        string redisKey = cacheType == CacheType.Dictionary
                                             ? key.Split('|')[0]
                                             : key.Split('_')[0];

                                        using (IDataSender sender = new RedisDataSender(redisKey))
                                        {
                                            sender.Send(entity);
                                            if (itemSet != null)
                                            {
                                                itemSet.SetUnChange();
                                            }
                                            Type   type      = entity.GetType();
                                            string entityKey = string.Format("{0},{1}", key, type.Assembly.GetName().Name);
                                            CacheChangeManager.Current.PutSql(entityKey);
                                        }
                                    }
                                }
                                catch (Exception e)
                                {
                                    TraceLog.WriteError("Redis sync key:{0} error:{1}", key, e);
                                }
                            }
                        }
                        finally
                        {
                            Monitor.Exit(syncObject);
                        }
                    }
                }
                catch (Exception ex)
                {
                    TraceLog.WriteError("Redis sync error:{0}", ex);
                }
            }