コード例 #1
0
        public ActionResult ViewItem(int id)
        {
            UserViewModel model;

            var db = CacheServer.Database;

            var tableName = Consts.Users;

            var keyName = "User_" + id;

            if (db.HashExists(tableName, keyName))
            {
                model = CacheServer.GetFromTable <UserViewModel>(tableName, keyName);
            }
            else
            {
                var user = _userService.GetByID(id);

                model = user.ToModel();

                CacheServer.AddToTable(tableName, keyName, model);
            }

            return(PartialView("ViewItem", model));
        }