hash_mset
Set multiple hash field-value pairs in Redis with a single command to optimize database operations and reduce network overhead.
Instructions
批量设置哈希字段
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | 哈希键名 | |
| fieldValues | Yes | 字段值对数组 |
Implementation Reference
- src/services/mcpService.ts:939-951 (handler)MCP tool handler for 'hash_mset' that ensures Redis connection and delegates to RedisService.hmsetprivate async handleHashMset(args: any) { this.ensureRedisConnection(); const result = await this.redisService!.hmset(args.key, args.fieldValues); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; }
- src/services/mcpService.ts:201-222 (schema)Input schema definition for the 'hash_mset' tool in the ListTools response{ name: 'hash_mset', description: '批量设置哈希字段', inputSchema: { type: 'object', properties: { key: { type: 'string', description: '哈希键名' }, fieldValues: { type: 'array', items: { type: 'object', properties: { field: { type: 'string', description: '字段名' }, value: { type: 'string', description: '字段值' } }, required: ['field', 'value'] }, description: '字段值对数组' } }, required: ['key', 'fieldValues'] }
- src/services/mcpService.ts:648-649 (registration)Dispatch/registration of 'hash_mset' handler in the CallToolRequest switch statementcase 'hash_mset': return await this.handleHashMset(args);
- src/services/redisService.ts:226-237 (helper)Core Redis HMSET implementation in RedisService that converts fieldValues array to object and calls underlying Redis client hSetasync hmset(key: string, fieldValues: RedisHashField[]): Promise<RedisOperationResult<number>> { return this.executeCommand(async () => { if (!this.client) throw new Error('Redis client not initialized'); const fields: Record<string, string> = {}; fieldValues.forEach(fv => { fields[fv.field] = fv.value; }); return await this.client.hSet(key, fields); }); }