string_mget
Retrieve multiple string values from Redis keys in a single operation to reduce network calls and improve performance when fetching multiple cached items or configuration settings.
Instructions
批量获取键值
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keys | Yes | 键名数组 |
Implementation Reference
- src/services/mcpService.ts:172-186 (registration)Registration of the string_mget tool in the ListTools response, including name, description, and input schema.{ name: 'string_mget', description: '批量获取键值', inputSchema: { type: 'object', properties: { keys: { type: 'array', items: { type: 'string' }, description: '键名数组' } }, required: ['keys'] } },
- src/services/mcpService.ts:905-917 (handler)The main handler function for the string_mget MCP tool. Ensures Redis connection, calls RedisService.mget, and returns formatted result.private async handleStringMget(args: any) { this.ensureRedisConnection(); const result = await this.redisService!.mget(args.keys); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; }
- src/services/mcpService.ts:642-643 (registration)Dispatch case in the CallToolRequest handler that routes string_mget calls to the specific handler.case 'string_mget': return await this.handleStringMget(args);
- src/services/redisService.ts:204-209 (helper)Helper method in RedisService that performs the actual MGET operation using the Redis client library.async mget(keys: string[]): Promise<RedisOperationResult<(string | null)[]>> { return this.executeCommand(async () => { if (!this.client) throw new Error('Redis client not initialized'); return await this.client.mGet(keys); }); }