Beispiel #1
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="value">更新后的数据</param>
        /// <param name="oldValue">更新前的数据</param>
        protected void onUpdated(valueType cacheValue, valueType value, valueType oldValue, fastCSharp.code.memberMap <modelType> memberMap)
        {
            int index = getIndex(value), oldIndex = getIndex(oldValue);

            if (index == oldIndex)
            {
                sortType sortKey = getSort(value), oldSortKey = getSort(oldValue);
                if (!sortKey.Equals(oldSortKey))
                {
                    fastCSharp.searchTree <sortType, valueType> tree = array[index].Value;
                    if (tree != null)
                    {
                        ++array[index].Version;
                        try
                        {
                            if (tree.Remove(oldSortKey))
                            {
                                tree.Add(sortKey, cacheValue);
                                return;
                            }
                        }
                        finally { ++array[index].Version; }
                    }
                    log.Error.Add(typeof(valueType).FullName + " 缓存同步错误", null, true);
                }
            }
            else
            {
                onInserted(cacheValue, index);
                onDeleted(oldValue, oldIndex);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 删除数据
 /// </summary>
 /// <param name="value">被删除的数据</param>
 protected virtual void onDeleted(valueType value)
 {
     if (!tree.Remove(getSort(value)))
     {
         log.Error.Add(typeof(valueType).FullName + " 缓存同步错误", null, true);
     }
 }
Beispiel #3
0
 /// <summary>
 /// 删除数据
 /// </summary>
 /// <param name="value">被删除的数据</param>
 /// <param name="index"></param>
 protected void onDeleted(valueType value, int index)
 {
     fastCSharp.searchTree <sortType, valueType> tree = array[index].Value;
     if (tree != null)
     {
         sortType sortKey = getSort(value);
         ++array[index].Version;
         try
         {
             if (tree.Remove(sortKey))
             {
                 return;
             }
         }
         finally { ++array[index].Version; }
     }
     log.Error.Add(typeof(valueType).FullName + " 缓存同步错误", null, true);
 }
Beispiel #4
0
        public int LoadDelete(keyType key)
        {
            cacheValue cacheValue;

            return(tree.Remove(key, out cacheValue) ? cacheValue.LogSize : 0);
        }