Skip to main content
Glama

key_ttl

Retrieve the remaining time-to-live (TTL) for a specific key in Redis, helping manage key expiration and optimize database performance.

Instructions

获取键过期时间

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes键名

Implementation Reference

  • The main handler function for the 'key_ttl' tool. It ensures a Redis connection exists, calls the ttl method on the RedisService with the provided key, formats the result as JSON text content, and returns it in the MCP response format.
    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) } ] }; }
  • The tool registration object returned by ListToolsRequestSchema handler. Defines the tool name, description, and input schema (requiring a 'key' string).
    { name: 'key_ttl', description: '获取键过期时间', inputSchema: { type: 'object', properties: { key: { type: 'string', description: '键名' } }, required: ['key'] } },
  • The switch case in the CallToolRequestSchema request handler that dispatches 'key_ttl' tool calls to the specific handleKeyTtl method.
    case 'key_ttl': return await this.handleKeyTtl(args);

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