Skip to main content
Glama

key_delete_pattern

Remove multiple Redis keys matching a specified pattern using wildcard support. Simplify Redis data management by efficiently deleting bulk keys based on search criteria.

Instructions

批量删除匹配的键

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYes匹配模式(支持通配符 * ? [])

Implementation Reference

  • MCP tool handler function that ensures Redis connection and delegates to redisService.deleteByPattern to perform the deletion.
    private async handleKeyDeletePattern(args: any) { this.ensureRedisConnection(); const result = await this.redisService!.deleteByPattern(args.pattern); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; }
  • Tool schema definition including input schema for pattern parameter.
    { name: 'key_delete_pattern', description: '批量删除匹配的键', inputSchema: { type: 'object', properties: { pattern: { type: 'string', description: '匹配模式(支持通配符 * ? [])' } }, required: ['pattern'] } },
  • Registration in the tool dispatch switch statement.
    case 'key_delete_pattern': return await this.handleKeyDeletePattern(args);
  • Helper function implementing the core logic: scans for keys matching the pattern using KEYS and deletes them using DEL.
    async deleteByPattern(pattern: string): Promise<RedisOperationResult<number>> { return this.executeCommand(async () => { if (!this.client) throw new Error('Redis client not initialized'); const keys = await this.client.keys(pattern); if (keys.length === 0) { return 0; } return await this.client.del(keys); }); }

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