feat: data export and import
This commit is contained in:
@@ -362,6 +362,27 @@ export class RedisStorage implements IStorage {
|
||||
|
||||
return configs;
|
||||
}
|
||||
|
||||
// 清空所有数据
|
||||
async clearAllData(): Promise<void> {
|
||||
try {
|
||||
// 获取所有用户
|
||||
const allUsers = await this.getAllUsers();
|
||||
|
||||
// 删除所有用户及其数据
|
||||
for (const username of allUsers) {
|
||||
await this.deleteUser(username);
|
||||
}
|
||||
|
||||
// 删除管理员配置
|
||||
await withRetry(() => this.client.del(this.adminConfigKey()));
|
||||
|
||||
console.log('所有数据已清空');
|
||||
} catch (error) {
|
||||
console.error('清空数据失败:', error);
|
||||
throw new Error('清空数据失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 单例 Redis 客户端
|
||||
|
||||
Reference in New Issue
Block a user