> 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` 会立即以共享缓存的局域网最高速度提供

在这种设置下，第二次访问既能以最高速度提供，使播放几乎是即时的，又能避免占用云端带宽。大型共享缓存实例几乎可以完全避免云端往返，除了第一次访问之外。

## 下载与设置

共享缓存是一个没有界面的终端可执行文件。你可以向我们索取可下载的版本。默认设置通常适用于大多数配置，这意味着对大多数人来说，通常只需双击即可启动。

## S3 支持

共享缓存支持同时使用本地（磁盘）后端和本地部署的 S3 目标来缓存数据。可以通过传入以下参数启用： `--storage-backend=s3` 以及端点、存储桶、区域、访问密钥和密钥。

## 配置选项

```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>           最大缓存大小（字节）（默认：500GB）
  --cache-check-interval <ms>        缓存清理间隔（毫秒）（默认：300000）
  --storage-backend <type>           存储后端：filesystem 或 s3（默认：filesystem）
  --discovery-server-name <name>     mDNS 服务名称（默认：Default Name）

  S3 存储选项（当 --storage-backend=s3 时）：
  --s3-endpoint <url>                S3 端点 URL
  --s3-bucket <name>                 S3 存储桶名称
  --s3-region <region>               S3 区域
  --s3-access-key-id <key>           S3 访问密钥 ID
  --s3-secret-access-key <secret>    S3 密钥访问密钥
  --s3-path-prefix <prefix>          S3 键前缀（可选）

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

环境变量：
  所有选项也可以通过使用大写蛇形命名法的环境变量来设置。
  例如：PORT、FS_WS_URL、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
```

## 加入共享缓存

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

如果没有弹出模态窗口，可以直接前往 设置 → 共享缓存 → 手动连接 并输入地址即可加入缓存。示例输入可能如下所示： `http://192.168.1.45:8003`

## 共享缓存无法工作？

如果共享缓存无法工作，或者你在网络中看不到其他设备：

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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
