fix 修复 一级缓存带来的问题

2.X
疯狂的狮子Li 1 year ago
parent 2712a38d63
commit ecf46323ec

@ -17,6 +17,7 @@ import org.dromara.common.core.utils.ip.AddressUtils;
import org.dromara.common.log.event.LogininforEvent; import org.dromara.common.log.event.LogininforEvent;
import org.dromara.common.redis.utils.RedisUtils; import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.common.satoken.utils.LoginHelper; import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.resource.api.RemoteMessageService; import org.dromara.resource.api.RemoteMessageService;
import org.dromara.system.api.RemoteUserService; import org.dromara.system.api.RemoteUserService;
import org.dromara.system.api.domain.SysUserOnline; import org.dromara.system.api.domain.SysUserOnline;
@ -55,18 +56,21 @@ public class UserActionListener implements SaTokenListener {
userOnline.setLoginTime(System.currentTimeMillis()); userOnline.setLoginTime(System.currentTimeMillis());
userOnline.setTokenId(tokenValue); userOnline.setTokenId(tokenValue);
String username = (String) loginModel.getExtra(LoginHelper.USER_NAME_KEY); String username = (String) loginModel.getExtra(LoginHelper.USER_NAME_KEY);
String tenantId = (String) loginModel.getExtra(LoginHelper.TENANT_KEY);
userOnline.setUserName(username); userOnline.setUserName(username);
userOnline.setClientKey((String) loginModel.getExtra(LoginHelper.CLIENT_KEY)); userOnline.setClientKey((String) loginModel.getExtra(LoginHelper.CLIENT_KEY));
userOnline.setDeviceType(loginModel.getDevice()); userOnline.setDeviceType(loginModel.getDevice());
userOnline.setDeptName((String) loginModel.getExtra(LoginHelper.DEPT_NAME_KEY)); userOnline.setDeptName((String) loginModel.getExtra(LoginHelper.DEPT_NAME_KEY));
if (tokenConfig.getTimeout() == -1) { TenantHelper.dynamic(tenantId, () -> {
RedisUtils.setCacheObject(CacheConstants.ONLINE_TOKEN_KEY + tokenValue, userOnline); if (tokenConfig.getTimeout() == -1) {
} else { RedisUtils.setCacheObject(CacheConstants.ONLINE_TOKEN_KEY + tokenValue, userOnline);
RedisUtils.setCacheObject(CacheConstants.ONLINE_TOKEN_KEY + tokenValue, userOnline, Duration.ofSeconds(tokenConfig.getTimeout())); } else {
} RedisUtils.setCacheObject(CacheConstants.ONLINE_TOKEN_KEY + tokenValue, userOnline, Duration.ofSeconds(tokenConfig.getTimeout()));
}
});
// 记录登录日志 // 记录登录日志
LogininforEvent logininforEvent = new LogininforEvent(); LogininforEvent logininforEvent = new LogininforEvent();
logininforEvent.setTenantId((String) loginModel.getExtra(LoginHelper.TENANT_KEY)); logininforEvent.setTenantId(tenantId);
logininforEvent.setUsername(username); logininforEvent.setUsername(username);
logininforEvent.setStatus(Constants.LOGIN_SUCCESS); logininforEvent.setStatus(Constants.LOGIN_SUCCESS);
logininforEvent.setMessage(MessageUtils.message("user.login.success")); logininforEvent.setMessage(MessageUtils.message("user.login.success"));

@ -49,7 +49,6 @@ public class PlusCacheWrapper implements Cache {
@Override @Override
public void put(Object key, Object value) { public void put(Object key, Object value) {
cache.put(key, value); cache.put(key, value);
CAFFEINE.put(key, value);
} }
public ValueWrapper putIfAbsent(Object key, Object value) { public ValueWrapper putIfAbsent(Object key, Object value) {

Loading…
Cancel
Save