コード例 #1
0
        protected override async ETTask Run(Session session, DBQueryRequest request, DBQueryResponse response, Action reply)
        {
            try
            {
                DBCacheComponent dbCacheComponent = Game.Scene.GetComponent <DBCacheComponent>();
                ComponentWithId  component        = await dbCacheComponent.Get(request.CollectionName, request.Id);

                response.Component = component;

                if (request.NeedCache && component != null)
                {
                    dbCacheComponent.AddToCache(component, request.CollectionName);
                }

                reply();
                await ETTask.CompletedTask;
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
コード例 #2
0
        protected override async void Run(Session session, DBQueryRequest message, Action <DBQueryResponse> reply)
        {
            DBQueryResponse response = new DBQueryResponse();

            try
            {
                DBCacheComponent dbCacheComponent = Game.Scene.GetComponent <DBCacheComponent>();
                ComponentWithId  component        = await dbCacheComponent.Get(message.CollectionName, message.Id);

                response.Component = component;

                if (message.NeedCache && component != null)
                {
                    dbCacheComponent.AddToCache(component, message.CollectionName);
                }

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }