# 缓存释放

## 缓存释放概述

free操作提供了强制驱逐数据的选项，用来手动释放缓存空间。

### 通过命令行释放缓存空间

用法: `bin/alluxio job free [flags]`

* 提交一个free任务:

```shell
$ {ALLUXIO_HOME}/bin/alluxio job free --path s3://bucket/path --submit
```

* 查看一个free任务的进度:

```shell
$ {ALLUXIO_HOME}/bin/alluxio job free --path s3://alluxio/path --progress
Progress for Free path file 's3://alluxio/path':
  Job Id: b21ce9fb-f332-4d39-8bb4-554f9a4fa601
  Job Submitted: Fri Feb 02 21:28:56 CST 2024
  Job path: s3://alluxio/path
  Job State: SUCCEEDED, finished at Fri Feb 02 21:29:01 CST 2024
  Free Info : totalFile:4 totalByte:3072.00KB
  Free Files Failed: 0
  Free Bytes Failed: 0B
  Free Files Succeeded: 4
  Free Bytes Succeeded: 3072.00KB
```

* 停止并中断一个正在运行的free任务:

  停止后，没有释放的文件依然会留在缓存中

```shell
$ {ALLUXIO_HOME}/bin/alluxio job free --path s3://alluxio/path --stop
```

```shell
参数描述：
--path [all] ufs路径
--batch-size [submit] 每秒每个worker释放文件的速度
--force [submit] 即使某些worker离线也触发释放
--verbose [progress] 输出free任务的详细信息
--format string [progress] 输出格式，TEXT或JSON（默认 "TEXT"）
```

### 通过REST API释放缓存空间

* 提交一个free任务:

```shell
curl -H "Content-Type: application/json" -v -X POST http://coordinator_host:19999/api/v1/master/submit_job/free -d '{
	"path": "s3://alluxio/path",
	"options": {
	"batchSize": "200"
	}
}'
```

* 查看一个free任务的进度:

```shell
curl -H "Content-Type: application/json" -v -X GET http://coordinator_host:19999/api/v1/master/progress_job/free -d '{
	"path": "s3://alluxio/path",
	"format": "JSON",
	"verbose": "true"
}'
```

* 停止并中断一个正在运行的free任务:

  停止后，没有释放的文件依然会留在缓存中

```shell
curl -H "Content-Type: application/json" -v -X POST http://coordinator_host:19999/api/v1/master/stop_job/free -d '{
	"path": "s3://alluxio/path"
}'
```

* 查询free任务列表：

```shell
curl http://ip:1999/api/v1/master/list_job?job-type=FREE[&job-state=[RUNNING|VERIFYING|STOPPED|SUCCEEDED|FAILED|ALL]]
```


---

# Agent Instructions: 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:

```
GET https://documentation.alluxio.io/ee-ai-cn/ai-3.3/feature/cache-free.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
