Skip to content

DOC-6957 Add Ruby (redis-rb) array data type examples - #3784

Open
andy-stark-redis wants to merge 1 commit into
mainfrom
DOC-6957-redis-rb-array-examples
Open

andy-stark-redis wants to merge 1 commit into
mainfrom
DOC-6957-redis-rb-array-examples

Conversation

@andy-stark-redis

@andy-stark-redis andy-stark-redis commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

DOC-6957 — Ruby (redis-rb) array data type examples

Adds local_examples/arrays_tutorial/ruby/dt_arrays.rb, giving the array data type page a Ruby tab across all eleven of its steps: arset_arget, armset_armget, len_count, argetrange, arscan, arinsert, arring, arlastitems, arop, argrep, ardel.

content/develop/data-types/arrays.md embeds clients-example with no lang_filter, so the Ruby tab appears automatically once the example pipeline regenerates examples.json — no page edit is needed, and none is in this PR. Existing tabs (6): Go, Java-Async, Java-Reactive, Node.js, PHP, Python.

Follow-up to DOC-6755, which created the arrays_tutorial set.

Verification

Run against released redis-rb v6.1.0 (redis-client 0.31.0, which ships lib/redis/commands/arrays.rb) on redis:8.12-rc3. The file ran unchanged: every REMOVE-block assertion held, and all printed values match their comments. arrays.rb at v6.1.0 is the same blob as when the examples were written, so no signature moved. AROP SUM and MAX print 60.0 and 30.0 (a bulk-string reply through Floatify), and ARSEEK prints true.

The examples build produces a Ruby tab for arrays_tutorial from this file. Verified on the rc3 image, not a GA image, because redis:8.12 was not yet on Docker Hub.

Not in this PR: redis_rb entries in the 18 data/command-api-mapping/AR*.json files, and ARINFO, which no tab in the set covers.

🤖 Generated with Claude Code


Note

Low Risk
Documentation-only addition of example scripts; runtime impact appears only after publish and only if readers use an unreleased redis-rb (called out as merge-blocked in the PR).

Overview
Adds local_examples/arrays_tutorial/ruby/dt_arrays.rb, a new Redis Ruby (redis-rb) walkthrough for the array data type tutorial. It mirrors the existing multi-language arrays_tutorial set with eleven stepped sections (arset_arget, armset_armget, sparse length/count, range/scan, insert/seek, ring buffer, last items, arop, argrep, delete) using the same STEP_START / STEP_END and hidden assert/cleanup blocks as the other client examples.

Once the examples pipeline refreshes examples.json, this should surface a Ruby tab on the arrays docs page alongside Go, Java, Node, PHP, and Python—no markdown changes in this diff.

Reviewed by Cursor Bugbot for commit e312724. Bugbot is set up for automated code reviews on this repo. Configure here.

@andy-stark-redis andy-stark-redis added do not merge yet parked PR speculatively added based on pre-release info. Check validity when release goes ahead. labels Aug 11, 2026
@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

DOC-6957

@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Redis Memory

Found 8 related items from repository history (3 new this commit):

Memory updated at e312724

Adds local_examples/arrays_tutorial/ruby/dt_arrays.rb, covering all 11 steps
that content/develop/data-types/arrays.md embeds. The page uses clients-example
with no lang_filter, so the Ruby tab appears once examples.json regenerates —
arrays.md itself needs no edit.

Written against redis-rb master (unreleased): AR* support landed in
redis/redis-rb#1371 on 2026-08-10, and the latest gem v6.0.0 (2026-07-31)
has no lib/redis/commands/arrays.rb. Hence PARKED.

## How the expected outputs were established

No Redis 8.8 with AR* was reachable (local server is 7.2.7, Docker daemon
down), so nothing here ran end-to-end. The values come from three separate
sources instead, which is worth knowing before trusting them:

1. Wire commands — VERIFIED BY EXECUTION. Replayed all 26 calls against the
   real redis-rb master (8a06ce6) in a throwaway git worktree with
   send_command stubbed, so no server was needed. Every call was accepted and
   serialized to the expected command array. This is what proves the keyword
   arguments are right (rev:, value:, with_values:, nocase:, logic:) — the
   error class most likely to be wrong when writing from docstrings.
2. Server reply values — INHERITED, NOT OBSERVED. Taken from the redis-py and
   predis examples in this same set, which agree with each other on every
   value. Two independent clients agreeing is good evidence about the wire,
   but it is still not an observation of Ruby's behaviour.
3. Ruby-side conversions — VERIFIED BY EXECUTION. arseek and arop are the only
   places Ruby diverges from the Python tab, because arrays.rb passes &Boolify
   and &Floatify. Fed the raw replies from (2) through the real lambdas:
   Boolify.call(1) => true, Floatify.call("60") => 60.0, ("30") => 30.0.

## The one expected output I would bet against

Floatify.call(60) returns Integer 60, not 60.0 — it only produces a Float from
a string. So `# 60.0` on the arop SUM/MAX lines is correct only if the server
replies with a bulk string. It does according to both redis-py (asserts "60")
and predis (asserts '60'), and both distinguish it from MATCH (integer 1), so
the inference is sound — but this is the single line most likely to be wrong
at unpark, and it will be wrong silently. Check arop first against a real 8.8.

## Deliberate choices

- Mirrors the redis-py file's structure: each step is preceded by a REMOVE
  block that deletes its keys, rather than doing the reset inside the visible
  snippet. Chose within-set parallelism over the pattern in
  local_examples/ruby/dt_hash.rb, so the rendered Ruby and Python tabs read
  the same. Also means no "recreate the key" comments.
- Directory is arrays_tutorial/ruby/, not arrays_tutorial/redis-rb/ — nine
  existing set dirs use `ruby`, and the language label in examples.json is
  `Ruby`.
- armset takes redis-rb's Hash form, which reads closer to redis-py's dict
  than a flat pair list would.
- arinfo is not covered, matching the other six clients in the set.

## Unpark verification (2026-11-24)

The park-time doubts are resolved. Ran the unchanged file end to end against
released redis-rb v6.1.0 (tag commit 9ee4d9a, redis-client 0.31.0) on a
redis:8.12-rc3 container (redis_version 8.11.242). Exit code 0, so every
REMOVE-block assertion held, and all 35 printed values match their trailing
comments in order. lib/redis/commands/arrays.rb at v6.1.0 is still blob
d32ec703, the park-time blob, so no signature moved.

- The arop bet was right: SUM and MAX print 60.0 and 30.0, so the server sends
  a bulk string and Floatify yields a Float. arseek prints true through Boolify.
- Ran the build/local_examples.py processor into a scratch directory. It
  produces a Ruby tab for arrays_tutorial from the .rb extension, and arrays.md
  has no lang_filter, so no page edit is needed.
- No code change was needed. The commit was rebased onto main (1239 commits
  behind, one added file, no conflicts); this message is the only rewrite.
- Not done here: the 18 AR* files in data/command-api-mapping/ still have no
  redis_rb entries. That is DOC-6957 scope but a separate PR, now that the gem
  is released.

Learned: verify a preemptive client example by executing the library with its transport stubbed, which separates "does the API accept this" from "does the server return that"; at unpark the same file passed unchanged against the released gem and a real server
Constraint: each STEP block is reset by the REMOVE block immediately before it, mirroring the redis-py file, so the rendered Ruby and Python tabs stay structurally parallel
Rejected: resetting inside the visible snippet (the local_examples/ruby/dt_hash.rb pattern) | breaks parity with the other six tabs in this set
Gaps: run on redis:8.12-rc3 rather than a GA image because redis:8.12 was not on Docker Hub; the AR* commands are a server preview feature, so re-run if their replies change
Ticket: DOC-6957
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@andy-stark-redis
andy-stark-redis force-pushed the DOC-6957-redis-rb-array-examples branch from cea879b to e312724 Compare November 24, 2026 09:38
@andy-stark-redis andy-stark-redis added clients Client library docs and removed do not merge yet parked PR speculatively added based on pre-release info. Check validity when release goes ahead. labels Nov 24, 2026
@andy-stark-redis
andy-stark-redis requested a review from a team November 24, 2026 09:49
@andy-stark-redis andy-stark-redis changed the title DOC-6957 Add Ruby (redis-rb) array data type examples [PARKED] DOC-6957 Add Ruby (redis-rb) array data type examples Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clients Client library docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant