key_expire
Set an expiration time for a Redis key in seconds using this tool. Input the key name and desired duration to manage data lifecycle effectively.
Instructions
设置键过期时间
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | 键名 | |
| seconds | Yes | 过期时间(秒) |
Implementation Reference
- src/services/mcpService.ts:1211-1223 (handler)The handler function that implements the key_expire MCP tool. It ensures Redis connection and calls redisService.expire(key, seconds), returning the result as text content.private async handleKeyExpire(args: any) { this.ensureRedisConnection(); const result = await this.redisService!.expire(args.key, args.seconds); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; }
- src/services/mcpService.ts:503-514 (schema)Tool metadata registration in ListTools response, including name, description, and input schema for validation.{ name: 'key_expire', description: '设置键过期时间', inputSchema: { type: 'object', properties: { key: { type: 'string', description: '键名' }, seconds: { type: 'number', description: '过期时间(秒)' } }, required: ['key', 'seconds'] } },
- src/services/mcpService.ts:688-689 (registration)Registration/dispatch case in the CallToolRequestHandler switch statement that routes to the key_expire handler.case 'key_expire': return await this.handleKeyExpire(args);