Skip to main content
Glama

key_ttl

Retrieve the remaining time before a Redis key expires to manage data lifecycle and optimize memory usage.

Instructions

获取键过期时间

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes键名

Implementation Reference

  • 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)
          }
        ]
      };
  • 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']
    }
  • 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']
      }
    },
  • Dispatcher case in CallToolRequest handler that routes key_ttl calls to the 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