Skip to main content
Glama

string_set

Store and manage string key-value pairs in Redis with optional expiration. Simplify data storage and retrieval using structured input parameters for efficient database operations.

Instructions

设置字符串键值

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expireSecondsNo过期时间(秒)(可选)
keyYes键名
valueYes

Implementation Reference

  • MCP tool handler for 'string_set'. Ensures Redis connection and delegates to RedisService.set with key, value, and optional expireSeconds.
    private async handleStringSet(args: any) { this.ensureRedisConnection(); const result = await this.redisService!.set(args.key, args.value, args.expireSeconds); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; }
  • Tool registration entry in listTools response, defining name, description, and input schema for validation.
    { name: 'string_set', description: '设置字符串键值', inputSchema: { type: 'object', properties: { key: { type: 'string', description: '键名' }, value: { type: 'string', description: '值' }, expireSeconds: { type: 'number', description: '过期时间(秒)(可选)' } }, required: ['key', 'value'] } },
  • Core Redis SET operation implementation that performs the actual Redis client.set call, handling optional expiration.
    async set(key: string, value: string, expireSeconds?: number): Promise<RedisOperationResult<string>> { return this.executeCommand(async () => { if (!this.client) throw new Error('Redis client not initialized'); if (expireSeconds !== undefined) { const result = await this.client.set(key, value, { EX: expireSeconds }); return result || 'OK'; } else { const result = await this.client.set(key, value); return result || 'OK'; } }); }

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