AB.CD数据库服务平台

高性能、高可用的数据库访问服务

✅ 运行中

🔌 连接管理

  • 连接池管理(2-10个连接)
  • 自动重连机制(最多3次)
  • 连接健康检查
  • 智能连接回收

⚡ 性能优化

  • 查询结果缓存(5分钟TTL)
  • 智能缓存失效机制
  • 文件缓存系统
  • CDN友好响应头

🛡️ 容错机制

  • 网络中断自动重试
  • 请求超时控制
  • 幂等性保护(防重复提交)
  • 优雅降级处理

📊 监控管理

  • 健康检查接口
  • 连接池实时监控
  • 详细的请求日志
  • 缓存命中率统计

📖 API接口文档

GET /health

健康检查接口

GET /health // 响应 { "success": true, "data": { "status": "healthy", "latency_ms": 2.35, "connections": { "total_connections": 5, "available": 3, "in_use": 2, "wait_queue": 0, "max_connections": 20 }, "timestamp": "2026-01-23 10:30:00" } }

GET /stats

系统状态统计

GET /stats // 响应 { "success": true, "data": { "system": { "php_version": "8.1.13", "memory_usage": "2.5MB", "peak_memory": "3.2MB", "load_time_ms": 15.23 }, "database": { "total_connections": 5, "available": 3, "in_use": 2, "wait_queue": 0, "max_connections": 10 }, "cache": { "enabled": true, "hits": 156, "misses": 23, "hit_rate": "87.2%" } } }

POST /cache/clear

清空查询缓存

POST /cache/clear // 响应 { "success": true, "data": { "message": "缓存已清空" } }

GET /tables/{table}

查询数据(支持条件过滤、分页、排序)

GET /tables/users?page=1&limit=20&status=active&order_by=id DESC // 响应 { "success": true, "data": { "data": [...], "pagination": { "page": 1, "limit": 20, "total": 156, "pages": 8 } } }

POST /tables/{table}

插入数据(支持批量插入,支持幂等性)

// 单条插入(支持幂等性保护) POST /tables/users Header: X-Idempotency-Key: unique-request-id { "name": "张三", "email": "zhangsan@example.com", "status": "active" } // 批量插入(不支持幂等性) POST /tables/users [ {"name": "张三", "email": "zhangsan@example.com"}, {"name": "李四", "email": "lisi@example.com"} ] // 响应 { "success": true, "data": { "id": 123, "affected_rows": 1 } }

POST /tables/{table}/update

更新数据(POST请求,更安全)

POST /tables/users/update { "data": { "status": "inactive", "updated_at": "2026-01-23 10:30:00" }, "conditions": { "id": 123 } }

POST /tables/{table}/delete

删除数据(POST请求,更安全)

POST /tables/users/delete { "id": 123 } // 或使用IN条件 POST /tables/users/delete { "id": [123, 124, 125] }

POST /schemas/{table}

创建数据表

POST /schemas/users { "columns": [ { "name": "id", "type": "INT", "attributes": ["AUTO_INCREMENT", "PRIMARY KEY"] }, { "name": "name", "type": "VARCHAR(100)", "attributes": ["NOT NULL"] }, { "name": "email", "type": "VARCHAR(255)", "attributes": ["NOT NULL", "UNIQUE"] }, { "name": "status", "type": "ENUM('active','inactive')", "attributes": ["DEFAULT 'active'"] } ] }

POST /schemas/{table}/delete

删除数据表(谨慎操作)

POST /schemas/users/delete // 响应 { "success": true, "data": { "message": "数据表删除成功" } }

POST /query

执行自定义查询(只读,仅支持SELECT)

POST /query { "sql": "SELECT * FROM users WHERE status = ? LIMIT ?", "params": ["active", 10], "types": "si" }

🔐 幂等性使用指南

为了防止重复提交,API支持幂等性保护机制:

// 在请求头中添加幂等性密钥 Header: X-Idempotency-Key: your-unique-key // 适用场景: // 1. 网络超时重试 // 2. 用户重复点击提交按钮 // 3. 消息队列重复消费 // 密钥要求: // - 长度:1-64字符 // - 格式:建议使用UUID或业务唯一ID // - 有效期:24小时 // - 仅对单条插入生效