Skip to main content
Glama

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
NameRequiredDescriptionDefault
keyYes哈希键名
fieldValuesYes字段值对数组

Implementation Reference

  • MCP tool handler for 'hash_mset' that ensures Redis connection and delegates to RedisService.hmset
    private 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) } ] }; }
  • 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'] }
  • Dispatch/registration of 'hash_mset' handler in the CallToolRequest switch statement
    case 'hash_mset': return await this.handleHashMset(args);
  • Core Redis HMSET implementation in RedisService that converts fieldValues array to object and calls underlying Redis client hSet
    async 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); }); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pickstar-2002/redis-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server