> For the complete documentation index, see [llms.txt](https://academy.shade.inc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://academy.shade.inc/shade-academy/shade-academy-zh/gong-xiang-huan-cun/using-shared-cache.md).

# 使用共享缓存

共享缓存是一台本地部署服务器，可让团队安全共享已被同一局域网内其他团队成员访问过的文件。

例如：

1. **团队成员 1** 访问 `large_video.mp4` 在连接到共享缓存时
2. ShadeFS 开始将该文件提供给 **团队成员 1** 来自云端
3. 在后台，共享缓存也开始缓存 `large_video.mp4`
4. 共享缓存完全完成缓存 `large_video.mp4`
5. **团队成员 2** 现在访问 `large_video.mp4` 在 ShadeFS 中
6. 共享缓存会运行权限检查以验证 **团队成员 2** 有权访问 `large_video.mp4`
7. `large_video.mp4` 会立即以局域网的最高速度从共享缓存提供

在这种设置下，第二次访问同样会以最高速度提供，因此播放几乎是即时的，并且避免了占用云端带宽。大型共享缓存实例几乎可以完全避免与云端往返，首次访问除外。

## 下载与安装

Shared Cache 是一个没有 UI 的终端可执行文件。你可以通过联系我们获取可下载版本。默认设置对大多数环境通常都是正确的，因此对大多数人来说，通常只需双击即可启动。

## S3 支持

Shared Cache 支持使用本地（磁盘）后端以及本地部署的 S3 目标来缓存数据。可通过传入以下参数启用： `--storage-backend s3` 以及 endpoint、bucket、region、access 和 secret。

## 配置选项

选项以以下格式传入： `--option value`。未识别的选项会被忽略且不会报错，因此请检查 Shared Cache 启动时打印的设置，以确认你的值已生效。

```bash
用法：shared-cache [options]

选项：
  --port <number>                          服务器端口（默认：8003）
  --fs-ws-url <url>                        上游 ShadeFS WebSocket URL（默认：wss://fs.shade.inc）
  --fs-api-url <url>                       上游 ShadeFS API URL（默认：https://fs.shade.inc）
  --local-cache-location <path>            缓存存储目录（默认：./cache）
  --database-location <path>               SQLite 数据库文件路径（默认：./shared_cache.db）
  --max-cache-size-bytes <bytes>           最大缓存大小（字节，默认：500GB）
  --cache-check-interval-ms <ms>           缓存清理间隔（毫秒，默认：300000）
  --storage-backend <type>                 存储后端：local 或 s3（默认：local）
  --discovery-server-name <name>           mDNS 服务名称（默认：默认名称）

  S3 存储选项（当 --storage-backend=s3 时）：
  --s3-endpoint <url>                      S3 endpoint URL
  --s3-bucket <name>                       S3 存储桶名称
  --s3-region <region>                     S3 区域
  --s3-access-key-id <key>                 S3 访问密钥 ID
  --s3-secret-access-key <secret>          S3 secret access key
  --s3-path-prefix <prefix>                S3 键前缀（可选）
  --s3-url-expiry-seconds <seconds>        预签名 URL 过期时间（默认：86400）

  高级选项：
  --download-worker-concurrent-chunks <n>  每个下载工作线程的并发分块数（默认：10）
  --download-worker-chunk-size <bytes>     下载分块大小（字节，默认：128MB）
  --version, -v                            显示版本信息
  --help, -h                               显示此帮助信息

环境变量：
  所有选项也可以通过环境变量设置，使用 SCREAMING_SNAKE_CASE。
  例如：PORT、FS_WS_URL、LOCAL_CACHE_LOCATION、MAX_CACHE_SIZE_BYTES 等。

示例：
  ./shared-cache --port 8080 --local-cache-location /var/cache/shade
  ./shared-cache --storage-backend s3 --s3-bucket my-bucket --s3-region us-east-1
  PORT=8080 LOCAL_CACHE_LOCATION=/var/cache/shade ./shared-cache
```

## 加入共享缓存

由于权限由 Shared Cache 处理，加入过程非常简单，而且不需要密码。共享缓存会通过 Bonjour 广播。在大多数情况下，同一网络中的客户端会检测到它，并弹出一个窗口询问是否要加入。

如果没有弹窗，可以直接通过进入 设置 → 共享缓存 → 手动连接 并输入地址来加入缓存。示例输入可能如下所示： `http://192.168.1.45:8003`

## Shared Cache 不工作？

如果 Shared Cache 无法工作，或者你在网络中看不到其他设备：

1. 打开 系统设置 → 隐私与安全 → 本地网络。
2. 确保 Shade 已启用。
3. 如果它被禁用了，请启用它并重新启动 Shade，然后再试一次。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://academy.shade.inc/shade-academy/shade-academy-zh/gong-xiang-huan-cun/using-shared-cache.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
