Reduce the request frequency to the Binance API and add backend caching.

This commit is contained in:
SkywalkerJi
2025-10-30 14:01:06 +08:00
parent 8dc32e61d0
commit 1171a4643c
6 changed files with 89 additions and 21 deletions

View File

@@ -50,7 +50,11 @@ export default function AILearning({ traderId }: AILearningProps) {
const { data: performance, error } = useSWR<PerformanceAnalysis>(
traderId ? `performance-${traderId}` : 'performance',
() => api.getPerformance(traderId),
{ refreshInterval: 10000 }
{
refreshInterval: 30000, // 30秒刷新AI学习分析数据更新频率较低
revalidateOnFocus: false,
dedupingInterval: 20000,
}
);
if (error) {

View File

@@ -33,8 +33,9 @@ export function ComparisonChart({ traders }: ComparisonChartProps) {
return Promise.all(promises);
},
{
refreshInterval: 10000,
refreshInterval: 30000, // 30秒刷新对比图表数据更新频率较低
revalidateOnFocus: false,
dedupingInterval: 20000,
}
);

View File

@@ -11,8 +11,9 @@ export function CompetitionPage() {
'competition',
api.getCompetition,
{
refreshInterval: 5000,
revalidateOnFocus: true,
refreshInterval: 15000, // 15秒刷新竞赛数据不需要太频繁更新
revalidateOnFocus: false,
dedupingInterval: 10000,
}
);

View File

@@ -34,7 +34,9 @@ export function EquityChart({ traderId }: EquityChartProps) {
traderId ? `equity-history-${traderId}` : 'equity-history',
() => api.getEquityHistory(traderId),
{
refreshInterval: 10000, // 每10秒刷新
refreshInterval: 30000, // 30秒刷新(历史数据更新频率较低)
revalidateOnFocus: false,
dedupingInterval: 20000,
}
);
@@ -42,7 +44,9 @@ export function EquityChart({ traderId }: EquityChartProps) {
traderId ? `account-${traderId}` : 'account',
() => api.getAccount(traderId),
{
refreshInterval: 5000,
refreshInterval: 15000, // 15秒刷新配合后端缓存
revalidateOnFocus: false,
dedupingInterval: 10000,
}
);