Skip to content

Conversation

@dougreese
Copy link

Overview

This series of commits adds support for quite a few Redis commands, including transaction support. The commands added are mainly to support the ChirpStack open-source LoRaWAN(R) Network Server, as well as an internal closed-source application.

Note that client-side caching is still not supported.

This includes pull request #1. They were added as separate pull requests due the them being very different.

These changes have been running in production with no issues.

Summary

This branch adds 21 new commands (including subcommands), significantly expanding the proxy's Redis compatibility. The major feature additions include:

  1. Full transaction support with command queuing
  2. Redis Streams support for event streaming
  3. Protocol negotiation and client management
  4. Enhanced key/hash operations with millisecond precision and float increments

Detailed Command List

Transaction Support

Added in commit 9f0193b

  • MULTI - Start a transaction and begin queuing commands
  • EXEC - Execute all queued commands atomically via Redis TxPipeline
  • DISCARD - Discard all queued commands and exit transaction
  • WATCH - Watch keys for changes (no-op implementation for client compatibility)
  • UNWATCH - Unwatch all keys (no-op implementation for client compatibility)

Implementation Details:

  • Commands are queued between MULTI and EXEC, then executed atomically
  • Per-connection state tracking maintains transaction state throughout the session
  • WATCH/UNWATCH return OK without Redis connection for performance (clients call UNWATCH frequently but don't typically use optimistic locking)

String/Key Operations

Added in commits 16743ac and 9f0193b

  • PSETEX - Set key with value and expiration in milliseconds
  • PEXPIRE - Set expiration on existing key in milliseconds
  • MGET - Get multiple keys at once

Hash Operations

Added in commit 9f0193b

  • HINCRBYFLOAT - Increment hash field by float value

Redis Streams

Added in commit 16743ac

  • XADD - Add entry to a stream
  • XREAD - Read entries from one or more streams
  • XGROUP - Manage consumer groups with subcommands:
    • CREATE - Create a new consumer group
    • SETID - Set the last delivered ID for a consumer group
    • DESTROY - Delete a consumer group
    • CREATECONSUMER - Create a consumer in a group
    • DELCONSUMER - Delete a consumer from a group
  • XREADGROUP - Read from stream as part of a consumer group
  • XACK - Acknowledge processed stream messages

Connection & Protocol Management

Added in commit d875fa4

  • HELLO - Protocol negotiation supporting RESP2 and RESP3

    • Accepts optional protocol version argument (defaults to RESP2)
    • Returns server information including server type, version, protocol version, client ID, mode, role, and loaded modules
  • CLIENT - Client connection management with subcommands:

    • SETNAME - Set client connection name
    • GETNAME - Get client connection name
    • ID - Get unique client ID
    • LIST - List all connected clients
    • KILL - Kill client connections
    • PAUSE - Pause client command processing
    • REPLY - Control server reply mode (ON/OFF/SKIP)
    • SETINFO - Set client library info (Redis 7.2+)
    • GETINFO - Get client information

Commands Previously Supported

For reference, the master branch supports:

Basic: PING, AUTH, QUIT, SELECT, INFO, CONFIG, DBSIZE, SCAN

String: GET, SET, SETEX, INCR, DECR, DEL, EXISTS, EXPIRE

Hash: HGET, HSET, HDEL

List: LPUSH, RPUSH, LPOP, RPOP

Set: SADD, SREM, SMEMBERS

Sorted Set: ZADD, ZREM, ZRANGE

Cluster: CLUSTER, MODULE

Testing

All new commands include comprehensive unit tests. Integration tests were added for Redis Streams functionality.

There is also a basic internationalization of docker-build.sh
Full list of commands added:
PSETEX, MGET, XADD, XREAD, XGROUP (CREATE, SETID, DESTROY,
CREATECONSUMER, DELCONSUMER), XREADGROUP, XACK

Added tests for these commands.
HELLO Command

- Supports protocol negotiation for RESP2 and RESP3
- Accepts optional protocol version argument (defaults to RESP2)
- Returns server information including:
  - Server type and version
  - Protocol version
  - Client ID
  - Server mode and role
  - Loaded modules list

CLIENT Command

Implemented with the following subcommands:
- SETNAME - Set client connection name
- GETNAME - Get client connection name
- ID - Get unique client ID
- LIST - List all connected clients
- KILL - Kill client connections
- PAUSE - Pause client command processing
- REPLY - Control server reply mode (ON/OFF/SKIP)
- SETINFO - Set client library info (Redis 7.2+)
- GETINFO - Get client information
Implement Redis transaction support with MULTI/EXEC/DISCARD commands
and true command queuing. Commands are queued between MULTI and EXEC,
then executed atomically via Redis TxPipeline.

New commands:
- MULTI, EXEC, DISCARD: Full transaction support
- WATCH, UNWATCH: No-op implementations for client compatibility
- PEXPIRE: Millisecond-precision key expiration
- HINCRBYFLOAT: Float increment for hash fields

Per-connection state tracking maintains transaction state throughout
the session lifetime. WATCH/UNWATCH return OK without Redis connection
for performance (client calls UNWATCH frequently but doesn't use
optimistic locking).
@dougreese dougreese changed the title Add commands feat(proxy) Add commands Dec 10, 2025
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.

1 participant