queue.func.php API参考文档
# queue.func.php API 参考文档
## 概述
`queue.func.php` 是 Xiuno BBS 的队列管理模块,使用 MySQL 模拟队列功能,提供了队列的查找、添加、弹出、删除、销毁、统计和垃圾回收等核心功能。
## 核心方法
### `queue_find()`
#### 说明
```php
function queue_find(string $queueid, int $page = 1, int $pagesize = 100): array
```
提取整个队列中的值。
#### 参数
- `$queueid`: 队列 ID
- `$page`: 页码,默认为 1
- `$pagesize`: 每页数量,默认为 100
#### 返回值
- 返回队列中的值列表
#### 示例
```php
$ids = queue_find('test_queue');
```
### `queue_push()`
#### 说明
```php
function queue_push(string $queueid, mixed $v, int $expiry = 0): bool
```
添加值到队列。
#### 参数
- `$queueid`: 队列 ID
- `$v`: 要添加的值
- `$expiry`: 过期时间,默认为 0(永久)
#### 返回值
- 成功返回 TRUE
- 失败返回 FALSE
#### 示例
```php
$r = queue_push('test_queue', 123);
```
### `queue_pop()`
#### 说明
```php
function queue_pop(string $queueid): mixed
```
弹出队列中的一个值。
#### 参数
- `$queueid`: 队列 ID
#### 返回值
- 成功返回弹出的值
- 失败返回 FALSE
#### 示例
```php
$value = queue_pop('test_queue');
```
### `queue_delete()`
#### 说明
```php
function queue_delete(string $queueid, mixed $v): bool
```
删除队列中的某个值。
#### 参数
- `$queueid`: 队列 ID
- `$v`: 要删除的值
#### 返回值
- 成功返回 TRUE
- 失败返回 FALSE
#### 示例
```php
$r = queue_delete('test_queue', 123);
```
### `queue_destory()`
#### 说明
```php
function queue_destory(string $queueid): bool
```
销毁某个队列。
#### 参数
- `$queueid`: 队列 ID
#### 返回值
- 成功返回 TRUE
- 失败返回 FALSE
#### 示例
```php
$r = queue_destory('test_queue');
```
### `queue_count()`
#### 说明
```php
function queue_count(string $queueid): int
```
统计队列中的值数量。
#### 参数
- `$queueid`: 队列 ID
#### 返回值
- 返回队列中的值数量
#### 示例
```php
$count = queue_count('test_queue');
```
### `queue_gc()`
#### 说明
```php
function queue_gc(): bool
```
清理过期的队列数据。
#### 参数
- 无参数
#### 返回值
- 成功返回 TRUE
- 失败返回 FALSE
#### 示例
```php
$r = queue_gc();
```