key_ttl
Retrieve the remaining time before a Redis key expires to manage data lifecycle and optimize memory usage.
Instructions
获取键过期时间
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | 键名 |
Implementation Reference
- src/services/mcpService.ts:1228-1239 (handler)The handler function that implements the key_ttl MCP tool. It ensures a Redis connection exists and calls the RedisService.ttl method with the provided key argument, returning the result as formatted text content.private async handleKeyTtl(args: any) { this.ensureRedisConnection(); const result = await this.redisService!.ttl(args.key); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] };
- src/services/mcpService.ts:518-524 (schema)Input schema definition for the key_ttl tool, specifying that a 'key' string parameter is required.inputSchema: { type: 'object', properties: { key: { type: 'string', description: '键名' } }, required: ['key'] }
- src/services/mcpService.ts:515-525 (registration)Tool registration in the ListTools response, defining name, description, and input schema for key_ttl.{ name: 'key_ttl', description: '获取键过期时间', inputSchema: { type: 'object', properties: { key: { type: 'string', description: '键名' } }, required: ['key'] } },
- src/services/mcpService.ts:690-691 (registration)Dispatcher case in CallToolRequest handler that routes key_ttl calls to the handleKeyTtl method.case 'key_ttl': return await this.handleKeyTtl(args);