示例#1
0
        /// <summary>
        /// 异步保存一个实体到db
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <returns></returns>
        public void SyncUpdateEntity <T>(T entity) where T : class, IDataEntity, new()
        {
            if (MangoDBConfig.IOCache)
            {
                var obj = UpdateEntityPool <T> .AcquireContent(this, entity);

                var ret = ThreadQueue.AppendIOCache(entity.GetHashCode(), obj.Update);
                if (ret == false)
                {
                    //  更新失败的话,则将自己的这个对象放回对象池
                    obj.Release();
                }
            }
            else
            {
                ThreadQueue.AppendIO(UpdateEntityPool <T> .AcquireContent(this, entity).Update);
            }
        }