Skip to content

Implement latency commands - #283

Draft
prateek-kumar-improving wants to merge 3 commits into
mainfrom
implement-latency-commands
Draft

Implement latency commands#283
prateek-kumar-improving wants to merge 3 commits into
mainfrom
implement-latency-commands

Conversation

@prateek-kumar-improving

@prateek-kumar-improving prateek-kumar-improving commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implement LATENCY HISTORY, LATENCY LATEST, and LATENCY RESET commands for both standalone and cluster clients.

Issue link

This Pull Request is linked to issue: #236

Features / Behaviour Changes

  • latencyHistory(string $event): array|false — Returns latency spike time series for the specified event as an array of [timestamp, duration_ms] pairs. Returns
    empty array if event does not exist.
  • latencyLatest(): array|false — Reports the latest latency events as an array of [event_name, timestamp, duration_ms, max_duration_ms] entries.
  • latencyReset(string ...$events): int|false — Resets latency data for specified events (or all events if none specified). Returns the number of events reset.
  • All three commands are available on both standalone (ValkeyGlide) and cluster (ValkeyGlideCluster) clients.

Implementation

  • Added execute_latency_history_command(), execute_latency_latest_command(), and execute_latency_reset_command() in valkey_glide_commands.c
  • All use STANDARD_METHOD_IMPL macro pattern
  • LatencyLatest registered as zero-arg operation, LatencyHistory/LatencyReset as message operations in valkey_glide_core_common.c
  • Uses process_core_array_result for history/latest and process_core_int_result for reset
  • Cluster stubs use @see only per review conventions

Limitations

  • PHPRedis does not have dedicated latency methods, so there is no PHPRedis signature to match. The API follows Valkey command semantics directly.
  • Tests use rawCommand for CONFIG GET/SET to trigger latency spikes, as config() is not yet available on the cluster client. Issue link: Implement config command in cluster #284

Testing

Tests run in both standalone and cluster mode (inherited).

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated.
  • CHANGELOG.md and documentation files are updated.
  • Destination branch is correct - main or release
  • Create merge commit if merging release branch into main, squash otherwise.

Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant