---
title: "更新缓存配置"
method: PUT
path: "/cache-manage/config"
tags: ["缓存管理"]
---

# 更新缓存配置

`PUT /cache-manage/config`

更新服务端音乐缓存的配置,如最大缓存大小和缓存目录。cache_dir 为空字符串时恢复使用默认目录。transcode_format 非空（mp3/m4a/ogg/flac/wav）时,缓存网络歌曲落盘会统一转码为该格式(缺 ffmpeg 或转码失败时保留原格式),transcode_quality 为可选码率(128/192/320,空或非法为最高质量)。更新后会自动触发 LRU 淘汰检查。切换目录时不会自动迁移旧缓存文件。

## Request body

- ServicesCacheConfig
  - `cache_dir` string — 自定义缓存目录，空字符串表示使用默认目录
  - `max_size` integer — 最大缓存大小（字节），0 表示无限制
  - `transcode_format` string — TranscodeFormat 缓存网络歌曲落盘时统一转码的目标格式（mp3/m4a/ogg/flac/wav）。 空字符串表示不转码、按上游原格式落盘（默认）。缺 ffmpeg 或转码失败时优雅降级保留原格式。
  - `transcode_quality` string — TranscodeQuality 转码目标码率（128/192/320），空或非法值表示最高质量。仅对有损格式生效。

## Response `200`

更新后的缓存配置

- ServicesCacheConfigResponse
  - `cache_dir` string
  - `default_cache_dir` string
  - `max_size` integer
  - `transcode_format` string
  - `transcode_quality` string

## Other responses

- `400` — 请求参数无效
- `500` — 更新失败

---

[API](https://skmtc.net/songloft-org/apis/songloft-api.md) · [All operations](https://skmtc.net/songloft-org/apis/songloft-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/songloft-org/songloft-api/versions/ee41778dbf8f/schema)
