perf:操作日志实时插入

This commit is contained in:
曾文豪
2024-08-27 13:32:15 +08:00
parent d96f17b847
commit 80ec6d2e3d

View File

@@ -23,7 +23,6 @@ import com.tiesheng.web.util.ProcessSyncConsumer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
@@ -32,11 +31,6 @@ import java.util.List;
@Service
public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLogOperation> {
/**
* 日志缓存
*/
private static final List<CoreLogOperation> cacheOperations = new ArrayList<>();
@Autowired
TieshengWebConfigurer tieshengWebConfigurer;
@Autowired
@@ -180,14 +174,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
if (params != null) {
operation.setParams(JSON.toJSONString(params));
}
synchronized (CoreLogOperation.class) {
cacheOperations.add(operation);
if (cacheOperations.size() >= 100) {
getBaseMapper().batchInsert(cacheOperations);
cacheOperations.clear();
}
}
save(operation);
}