Repository navigation
DOC-6957 Add Ruby (redis-rb) array data type examples - #3784
Open
andy-stark-redis wants to merge 1 commit into
Open
andy-stark-redis wants to merge 1 commit into
andy-stark-redis wants to merge 1 commit into
Conversation
Contributor
Contributor
🧠 Redis MemoryFound 8 related items from repository history (3 new this commit):
Memory updated at e312724 |
This was referenced Aug 25, 2026
This was referenced Oct 13, 2026
This was referenced Nov 9, 2026
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
force-pushed
the
DOC-6957-redis-rb-array-examples
branch
from
November 24, 2026 09:38
cea879b to
e312724
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.mdembedsclients-examplewith nolang_filter, so the Ruby tab appears automatically once the example pipeline regeneratesexamples.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_tutorialset.Verification
Run against released redis-rb v6.1.0 (redis-client 0.31.0, which ships
lib/redis/commands/arrays.rb) onredis:8.12-rc3. The file ran unchanged: everyREMOVE-block assertion held, and all printed values match their comments.arrays.rbat v6.1.0 is the same blob as when the examples were written, so no signature moved.AROPSUM and MAX print60.0and30.0(a bulk-string reply throughFloatify), andARSEEKprintstrue.The examples build produces a
Rubytab forarrays_tutorialfrom this file. Verified on therc3image, not a GA image, becauseredis:8.12was not yet on Docker Hub.Not in this PR:
redis_rbentries in the 18data/command-api-mapping/AR*.jsonfiles, andARINFO, 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-languagearrays_tutorialset with eleven stepped sections (arset_arget,armset_armget, sparse length/count, range/scan, insert/seek, ring buffer, last items,arop,argrep, delete) using the sameSTEP_START/STEP_ENDand 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.