Revert: 撤销 584fa8c 之后的所有提交

This commit is contained in:
SunSeekerX
2026-01-03 23:24:59 +08:00
parent 74e71d0afc
commit 90023d1551
27 changed files with 219 additions and 488 deletions

View File

@@ -71,9 +71,7 @@ class ApiKeyIndexService {
* 扫描所有 API Key确保 hash -> keyId 映射存在
*/
async rebuildHashMap() {
if (!this.redis) {
return
}
if (!this.redis) return
try {
const client = this.redis.getClientSafe()
@@ -189,9 +187,7 @@ class ApiKeyIndexService {
const pipeline = client.pipeline()
for (const apiKey of apiKeys) {
if (!apiKey || !apiKey.id) {
continue
}
if (!apiKey || !apiKey.id) continue
const keyId = apiKey.id
const createdAt = apiKey.createdAt ? new Date(apiKey.createdAt).getTime() : 0
@@ -253,9 +249,7 @@ class ApiKeyIndexService {
* 添加单个 API Key 到索引
*/
async addToIndex(apiKey) {
if (!this.redis || !apiKey || !apiKey.id) {
return
}
if (!this.redis || !apiKey || !apiKey.id) return
try {
const client = this.redis.getClientSafe()
@@ -303,9 +297,7 @@ class ApiKeyIndexService {
* 更新索引(状态、名称、标签变化时调用)
*/
async updateIndex(keyId, updates, oldData = {}) {
if (!this.redis || !keyId) {
return
}
if (!this.redis || !keyId) return
try {
const client = this.redis.getClientSafe()
@@ -384,9 +376,7 @@ class ApiKeyIndexService {
* 从索引中移除 API Key
*/
async removeFromIndex(keyId, oldData = {}) {
if (!this.redis || !keyId) {
return
}
if (!this.redis || !keyId) return
try {
const client = this.redis.getClientSafe()
@@ -608,9 +598,7 @@ class ApiKeyIndexService {
* 更新 lastUsedAt 索引(供 recordUsage 调用)
*/
async updateLastUsedAt(keyId, lastUsedAt) {
if (!this.redis || !keyId) {
return
}
if (!this.redis || !keyId) return
try {
const client = this.redis.getClientSafe()