Skip to content

Conversation

@JC1738
Copy link

@JC1738 JC1738 commented Jan 15, 2026

Adds three scalar functions for managing key time-to-live in Redis:

  • redis_expire(key, seconds, secret): Set TTL in seconds, returns TRUE if set
  • redis_ttl(key, secret): Get remaining TTL (-2=key not exist, -1=no expiry)
  • redis_expireat(key, timestamp, secret): Set expiry at Unix timestamp, returns TRUE

Implementation details:

  • Added 4 protocol formatters to RedisProtocol class
  • Added parseIntegerResponse() helper for parsing integer responses
  • Updated extension version from 2025120401 to 2026011401
  • Added error-handling tests for non-existent secrets
  • Updated documentation with features, reference table, and usage examples

All functions follow existing patterns and pass unit tests. Live-tested against local Redis instance - all TTL operations working correctly.

@CLAassistant
Copy link

CLAassistant commented Jan 15, 2026

CLA assistant check
All committers have signed the CLA.

@JC1738 JC1738 mentioned this pull request Jan 15, 2026
@JC1738 JC1738 marked this pull request as draft January 15, 2026 07:29
Implements complete Time-To-Live operations with proper error handling
and optimization. Adds 3 scalar functions matching Redis protocol.

## Features
- redis_expire(key, seconds, secret) → Set TTL in seconds
- redis_ttl(key, secret) → Get remaining TTL (-2/-1/positive)
- redis_expireat(key, timestamp, secret) → Set expiry at Unix timestamp

## Implementation
- 4 protocol formatters (formatExpire, formatExpireAt, formatTtl, parseIntegerResponse)
- Error handling with try-catch blocks
- Secret access optimization (extract once before loops)
- Follows AGENTS.md patterns

## Files changed
- src/redis_extension.cpp: +135/-2 lines
- docs/README.md: +20 lines
- test/sql/redis.test: +15 lines
- .gitignore: +5 lines
@JC1738 JC1738 marked this pull request as ready for review January 15, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants