perf:操作日志实时插入
This commit is contained in:
@@ -23,7 +23,6 @@ import com.tiesheng.web.util.ProcessSyncConsumer;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,11 +31,6 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLogOperation> {
|
public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLogOperation> {
|
||||||
|
|
||||||
/**
|
|
||||||
* 日志缓存
|
|
||||||
*/
|
|
||||||
private static final List<CoreLogOperation> cacheOperations = new ArrayList<>();
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
TieshengWebConfigurer tieshengWebConfigurer;
|
TieshengWebConfigurer tieshengWebConfigurer;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -180,14 +174,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
|||||||
if (params != null) {
|
if (params != null) {
|
||||||
operation.setParams(JSON.toJSONString(params));
|
operation.setParams(JSON.toJSONString(params));
|
||||||
}
|
}
|
||||||
|
save(operation);
|
||||||
synchronized (CoreLogOperation.class) {
|
|
||||||
cacheOperations.add(operation);
|
|
||||||
if (cacheOperations.size() >= 100) {
|
|
||||||
getBaseMapper().batchInsert(cacheOperations);
|
|
||||||
cacheOperations.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user