# HTTPCacheTaskService
> 缓存任务管理

---

## countDoingHTTPCacheTasks
> 计算正在执行的任务数量

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/HTTPCacheTaskService/countDoingHTTPCacheTasks`
- RPC：`rpc countDoingHTTPCacheTasks(CountDoingHTTPCacheTasksRequest) returns (RPCCountResponse);`

**请求对象 (`CountDoingHTTPCacheTasksRequest`)**

```json
{}
```

**响应对象 (`RPCCountResponse`)**

```json
{
  "count": "int64 // 数量"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/HTTPCacheTaskService/countDoingHTTPCacheTasks" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## countHTTPCacheTasks
> 计算任务总数量

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/HTTPCacheTaskService/countHTTPCacheTasks`
- RPC：`rpc countHTTPCacheTasks(CountHTTPCacheTasksRequest) returns (RPCCountResponse);`

**请求对象 (`CountHTTPCacheTasksRequest`)**

```json
{}
```

**响应对象 (`RPCCountResponse`)**

```json
{
  "count": "int64 // 数量"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/HTTPCacheTaskService/countHTTPCacheTasks" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## createHTTPCacheTask
> 创建任务

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/HTTPCacheTaskService/createHTTPCacheTask`
- RPC：`rpc createHTTPCacheTask(CreateHTTPCacheTaskRequest) returns (CreateHTTPCacheTaskResponse);`

**请求对象 (`CreateHTTPCacheTaskRequest`)**

```json
{
  "type": "string // 任务类型，值为 purge 或者 fetch；purge：删除缓存，fetch：预热缓存",
  "keyType": "string // Key类型，值为 key 或者 prefix；如果是 key 表示处理的是URL，如果是 prefix 表示处理的是目录；预热的时候只能为 key",
  "keys": "[]string // 要清理的Key，根据Key类型（keyType）来输入不同的内容"
}
```

**响应对象 (`CreateHTTPCacheTaskResponse`)**

```json
{
  "httpCacheTaskId": "int64 // 生成的任务ID",
  "countKeys": "int64 // 任务中包含的Key"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/HTTPCacheTaskService/createHTTPCacheTask" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## deleteHTTPCacheTask
> 删除任务

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/HTTPCacheTaskService/deleteHTTPCacheTask`
- RPC：`rpc deleteHTTPCacheTask(DeleteHTTPCacheTaskRequest) returns (RPCSuccess);`

**请求对象 (`DeleteHTTPCacheTaskRequest`)**

```json
{
  "httpCacheTaskId": "int64 // 任务ID"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/HTTPCacheTaskService/deleteHTTPCacheTask" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## findEnabledHTTPCacheTask
> 查找单个任务

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/HTTPCacheTaskService/findEnabledHTTPCacheTask`
- RPC：`rpc findEnabledHTTPCacheTask(FindEnabledHTTPCacheTaskRequest) returns (FindEnabledHTTPCacheTaskResponse);`

**请求对象 (`FindEnabledHTTPCacheTaskRequest`)**

```json
{
  "httpCacheTaskId": "int64 // 任务ID"
}
```

**响应对象 (`FindEnabledHTTPCacheTaskResponse`)**

```json
{
  "httpCacheTask": "HTTPCacheTask // 任务信息"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/HTTPCacheTaskService/findEnabledHTTPCacheTask" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## listHTTPCacheTasks
> 列出单页任务

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/HTTPCacheTaskService/listHTTPCacheTasks`
- RPC：`rpc listHTTPCacheTasks(ListHTTPCacheTasksRequest) returns (ListHTTPCacheTasksResponse);`

**请求对象 (`ListHTTPCacheTasksRequest`)**

```json
{
  "offset": "int64 // 查询起始位置",
  "size": "int64 // 查询条数"
}
```

**响应对象 (`ListHTTPCacheTasksResponse`)**

```json
{
  "httpCacheTasks": "[]HTTPCacheTask // 一组任务信息"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/HTTPCacheTaskService/listHTTPCacheTasks" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## resetHTTPCacheTask
> 重置任务状态

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/HTTPCacheTaskService/resetHTTPCacheTask`
- RPC：`rpc resetHTTPCacheTask(ResetHTTPCacheTaskRequest) returns (RPCSuccess);`

**请求对象 (`ResetHTTPCacheTaskRequest`)**

```json
{
  "httpCacheTaskId": "int64 // 任务ID"
}
```

**响应对象 (`RPCSuccess`)**

```json
{}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/HTTPCacheTaskService/resetHTTPCacheTask" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---
