/// <summary>
 ///
 /// </summary>
 /// <param name="enumerable"></param>
 /// <param name="period"></param>
 public static bool AddRange(IEnumerable <ShareEntity> enumerable, int period = 0)
 {
     if (DataSyncQueueManager.SendSync(enumerable))
     {
         foreach (var t in enumerable)
         {
             CacheItemSet itemSet;
             if (CacheFactory.AddOrUpdateEntity(t, out itemSet, period))
             {
                 itemSet.OnLoadSuccess();
             }
         }
         return(true);
     }
     return(false);
 }
Exemple #2
0
        /// <summary>
        /// Initialize cache.
        /// </summary>
        /// <param name="dbTransponder">db trans object</param>
        /// <param name="redisTransponder">redis trans object</param>
        /// <param name="setting">setting.</param>
        /// <param name="serializer"></param>
        public static void Initialize(ITransponder dbTransponder, ITransponder redisTransponder, CacheSetting setting, ICacheSerializer serializer)
        {
            _readonlyPools = new CachePool(dbTransponder, redisTransponder, true, serializer);
            _writePools    = new CachePool(dbTransponder, redisTransponder, false, serializer)
            {
                Setting = setting
            };

            EntitySchemaSet.InitSchema(typeof(EntityHistory));
            DataSyncQueueManager.Start(setting, serializer);
            ProfileManager.Start();
            InitListener("__CachePoolListener", setting.ExpiredInterval, "__CachePoolUpdateListener", setting.UpdateInterval);
            if (setting.AutoRunEvent)
            {
                StartListener();
            }
        }
Exemple #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="checkMutilKey">The entity need to reload when it has be mutil key</param>
 /// <param name="enumerable"></param>
 public static bool AddRange(bool checkMutilKey, params BaseEntity[] enumerable)
 {
     if (DataSyncQueueManager.SendSync(enumerable))
     {
         foreach (var t in enumerable)
         {
             var          schema = t.GetSchema();
             CacheItemSet itemSet;
             if (CacheFactory.AddOrUpdateEntity(t, out itemSet))
             {
                 if (checkMutilKey && schema.Keys.Length > 1 && !itemSet.HasLoadSuccess)
                 {
                     ReLoad(t.PersonalId, schema);
                 }
                 else
                 {
                     itemSet.OnLoadSuccess();
                 }
             }
         }
         return(true);
     }
     return(false);
 }
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="V"></typeparam>
 /// <param name="dataList"></param>
 /// <returns></returns>
 public bool SendSync <V>(IEnumerable <V> dataList) where V : AbstractEntity, new()
 {
     return(DataSyncQueueManager.SendSync(dataList));
 }