Open leeaee opened 6 years ago
When adding AAA required permission checking logic, the query user's SQL will execute three times for every time call.
@GetAction("{id}") public Admin read(@NotNull Long id, String fields) { AAA.requirePermission(Permissions.PERM_ADMIN_READ); PropertySpec.current.set(fields); Admin admin = dao.findById(id); notFoundIfNull(admin, context.i18n(Messages.ENTITY_ID_NOT_FOUND, Admin.KEY, id)); logger.debug("Read admin by id -> {}", id); return admin; }
When call read admin method. the logs shows the query login user with execute 3 times.
16:07:41.670 [XNIO-1 task-3] DEBUG e.logging.sql - SELECT ID, create_time, EMAIL, last_update, login_name, MOBILE, NAME, PASSWORD, PHONE, ROLES, SALT, STATE, VERSION FROM bb_admin WHERE (login_name = ?) bind => [admin] 16:07:41.672 [XNIO-1 task-3] DEBUG e.logging.sql - SELECT ID, create_time, EMAIL, last_update, login_name, MOBILE, NAME, PASSWORD, PHONE, ROLES, SALT, STATE, VERSION FROM bb_admin WHERE (login_name = ?) bind => [admin] 16:07:41.673 [XNIO-1 task-3] DEBUG e.logging.sql - SELECT ID, create_time, EMAIL, last_update, login_name, MOBILE, NAME, PASSWORD, PHONE, ROLES, SALT, STATE, VERSION FROM bb_admin WHERE (login_name = ?) bind => [admin] 16:07:41.675 [XNIO-1 task-3] DEBUG e.logging.sql - SELECT ID, create_time, EMAIL, last_update, login_name, MOBILE, NAME, PASSWORD, PHONE, ROLES, SALT, STATE, VERSION FROM bb_admin WHERE (ID = ?) bind => [1] 16:07:41.676 [XNIO-1 task-3] DEBUG c.b.n.a.AdminEndpoint - Read admin by id -> 1
Is there any way to optimize this?
@leeaee the cache mechanism introduced with #32 should fixed the issue.
When adding AAA required permission checking logic, the query user's SQL will execute three times for every time call.
When call read admin method. the logs shows the query login user with execute 3 times.
Is there any way to optimize this?