yingfeng64 Claude Sonnet 4.6 commited on
Commit
47bccb9
·
1 Parent(s): b71d1f2

Add optional ts_code filter to GET /api/v1/cache

Browse files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -297,13 +297,18 @@ async def get_predict_result(task_id: str):
297
 
298
 
299
  @app.get("/api/v1/cache", summary="查看缓存状态")
300
- async def get_cache():
301
  """
302
- 列出当前所效的缓存条目及其过期时间。
 
 
 
303
  """
304
  now_utc = datetime.now(timezone.utc)
305
  entries = []
306
  for key, entry in _cache.items():
 
 
307
  remaining = (entry["expires_at"] - now_utc).total_seconds()
308
  if remaining > 0:
309
  entries.append({
 
297
 
298
 
299
  @app.get("/api/v1/cache", summary="查看缓存状态")
300
+ async def get_cache(ts_code: str | None = None):
301
  """
302
+ 列出有效的缓存条目及其过期时间。
303
+
304
+ - 不传参数:返回全部
305
+ - `?ts_code=000063.SZ`:只返回该股票的所有参数组合
306
  """
307
  now_utc = datetime.now(timezone.utc)
308
  entries = []
309
  for key, entry in _cache.items():
310
+ if ts_code and key[0] != ts_code:
311
+ continue
312
  remaining = (entry["expires_at"] - now_utc).total_seconds()
313
  if remaining > 0:
314
  entries.append({