Files
JRedisDesktop/electron/main/redis/server.ts
T
Jokul bdcf4fe299 refactor: restructure project layout
- Move main process to electron/main/
- Move preload to electron/preload/
- Add shared types in electron/shared/
- Split redis-service into modular redis/ directory
- Flatten renderer to src/ (remove src/renderer/ nesting)
- Update electron.vite.config.ts paths
- Update tsconfig paths
- Output to electron-dist/
2026-07-04 21:12:50 +08:00

46 lines
1.5 KiB
TypeScript

// src/main/redis/server.ts
// 服务器操作
import { getClient } from './connection'
export async function execute(id: string, command: string, args: string[]): Promise<unknown> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
return client.call(command, ...args)
}
export async function getServerInfo(id: string): Promise<string> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
return client.info() as Promise<string>
}
export async function selectDb(id: string, db: number): Promise<void> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
await client.select(db)
}
export async function dbSize(id: string): Promise<number> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
return client.dbsize() as Promise<number>
}
export async function ping(id: string): Promise<string> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
return client.ping()
}
export async function slowLogGet(id: string, count: number): Promise<any[]> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
return client.slowlog('GET', count) as Promise<any[]>
}
export async function slowLogLen(id: string): Promise<number> {
const client = getClient(id)
if (!client) throw new Error(`Client ${id} not found`)
return client.slowlog('LEN') as Promise<number>
}