mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-24 06:24:47 +00:00
feat: 大规模性能优化 - Redis Pipeline 批量操作、索引系统、连接池优化
This commit is contained in:
@@ -73,6 +73,7 @@ class BedrockAccountService {
|
||||
|
||||
const client = redis.getClientSafe()
|
||||
await client.set(`bedrock_account:${accountId}`, JSON.stringify(accountData))
|
||||
await redis.addToIndex('bedrock_account:index', accountId)
|
||||
|
||||
logger.info(`✅ 创建Bedrock账户成功 - ID: ${accountId}, 名称: ${name}, 区域: ${region}`)
|
||||
|
||||
@@ -127,11 +128,17 @@ class BedrockAccountService {
|
||||
async getAllAccounts() {
|
||||
try {
|
||||
const client = redis.getClientSafe()
|
||||
const keys = await client.keys('bedrock_account:*')
|
||||
const accountIds = await redis.getAllIdsByIndex(
|
||||
'bedrock_account:index',
|
||||
'bedrock_account:*',
|
||||
/^bedrock_account:(.+)$/
|
||||
)
|
||||
const keys = accountIds.map((id) => `bedrock_account:${id}`)
|
||||
const accounts = []
|
||||
const dataList = await redis.batchGetChunked(keys)
|
||||
|
||||
for (const key of keys) {
|
||||
const accountData = await client.get(key)
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const accountData = dataList[i]
|
||||
if (accountData) {
|
||||
const account = JSON.parse(accountData)
|
||||
|
||||
@@ -280,6 +287,7 @@ class BedrockAccountService {
|
||||
|
||||
const client = redis.getClientSafe()
|
||||
await client.del(`bedrock_account:${accountId}`)
|
||||
await redis.removeFromIndex('bedrock_account:index', accountId)
|
||||
|
||||
logger.info(`✅ 删除Bedrock账户成功 - ID: ${accountId}`)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user