Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions local_examples/cmds_generic/node-redis/cmds-generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,17 @@ await client.del(['geokey', 'zkey']);
const scan4Res1 = await client.hSet('myhash', { a: 1, b: 2 });
console.log(scan4Res1); // 2

// HSCAN doesn't promise a field order, so pair entries into an object rather than
// relying on position.
const scan4Res2 = await client.hScan('myhash', '0');
console.log(scan4Res2.entries); // [{field: 'a', value: '1'}, {field: 'b', value: '2'}]
const scan4Pairs = Object.fromEntries(scan4Res2.entries.map((e) => [e.field, e.value]));
console.log(scan4Pairs); // {a: '1', b: '2'}
// REMOVE_START
assert.deepEqual(scan4Res2.entries, [
{ field: 'a', value: '1' },
{ field: 'b', value: '2' }
]);
assert.deepEqual(scan4Pairs, { a: '1', b: '2' });
// REMOVE_END

const scan4Res3 = await client.hScan('myhash', '0', { COUNT: 10 });
const items = scan4Res3.entries.map((item) => item.field)
const items = scan4Res3.entries.map((item) => item.field).sort()
console.log(items); // ['a', 'b']
// REMOVE_START
assert.deepEqual(items, ['a', 'b'])
Expand Down
4 changes: 2 additions & 2 deletions local_examples/cmds_generic/redis-py/cmds_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@
# REMOVE_END

cursor, keys = r.hscan("myhash", 0, no_values=True)
print(keys)
print(sorted(keys))
# >>> ['a', 'b']
# REMOVE_START
assert keys == ['a', 'b']
assert sorted(keys) == ['a', 'b']
# REMOVE_END

# REMOVE_START
Expand Down
3 changes: 2 additions & 1 deletion local_examples/cmds_hash/node-redis/cmds-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ const res12 = await client.hSet(
}
)

const res13 = await client.hVals('myhash')
// HVALS follows the hash's field order, which Redis does not promise, so sort.
const res13 = (await client.hVals('myhash')).sort()
console.log(res13) // [ 'Hello', 'World' ]

// REMOVE_START
Expand Down
2 changes: 2 additions & 0 deletions local_examples/cmds_hash/predis/CmdsHashTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ public function testCmdsHash(): void
$hValsResult1 = $this->redis->hmset('myhash', ['field1' => 'Hello', 'field2' => 'World']);
echo "HMSET myhash field1 Hello field2 World: " . ($hValsResult1 ? 'OK' : 'FAIL') . "\n"; // >>> OK

// HVALS follows the hash's field order, which Redis does not promise, so sort.
$hValsResult2 = $this->redis->hvals('myhash');
sort($hValsResult2);
echo "HVALS myhash: " . json_encode($hValsResult2) . "\n"; // >>> ["Hello","World"]
// STEP_END

Expand Down
5 changes: 3 additions & 2 deletions local_examples/cmds_hash/redis-py/cmds_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,12 @@
# STEP_START hvals
res10 = r.hset("myhash", mapping={"field1": "Hello", "field2": "World"})

# HVALS follows the hash's field order, which Redis does not promise, so sort.
res11 = r.hvals("myhash")
print(res11) # >>> [ "Hello", "World" ]
print(sorted(res11)) # >>> [ "Hello", "World" ]

# REMOVE_START
assert res11 == [ "Hello", "World" ]
assert sorted(res11) == [ "Hello", "World" ]
r.delete("myhash")
# REMOVE_END
# STEP_END
Expand Down
3 changes: 2 additions & 1 deletion local_examples/cmds_hash/ruby/cmds_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def assert_equal(expected, actual)
# STEP_START hvals
r.hset('myhash', { 'field1' => 'Hello', 'field2' => 'World' })

res15 = r.hvals('myhash')
# HVALS follows the hash's field order, which Redis does not promise, so sort.
res15 = r.hvals('myhash').sort
puts res15.inspect # >>> ["Hello", "World"]
# STEP_END

Expand Down
2 changes: 1 addition & 1 deletion local_examples/ruby/dt_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def assert_equal(expected, actual)

res4 = r.hgetall('bike:1')
puts res4.inspect
# >>> {"model"=>"Deimos", "brand"=>"Ergonom", "type"=>"Enduro bikes", "price"=>"4972"}
# >>> {"model" => "Deimos", "brand" => "Ergonom", "type" => "Enduro bikes", "price" => "4972"}
# STEP_END

# REMOVE_START
Expand Down
52 changes: 26 additions & 26 deletions local_examples/ruby/dt_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
# HIDE_END
res4 = r.xrange('race:france', '1692632086370-0', '+', count: 2)
puts res4.inspect
# >>> [["1692632086370-0", {"rider"=>"Castilla", "speed"=>"30.2", "position"=>"1", "location_id"=>"1"}],
# ["1692632094485-0", {"rider"=>"Norem", "speed"=>"28.8", "position"=>"3", "location_id"=>"1"}]]
# >>> [["1692632086370-0", {"rider" => "Castilla", "speed" => "30.2", "position" => "1", "location_id" => "1"}],
# ["1692632094485-0", {"rider" => "Norem", "speed" => "28.8", "position" => "3", "location_id" => "1"}]]
# STEP_END

# REMOVE_START
Expand Down Expand Up @@ -181,10 +181,10 @@
# HIDE_END
res11 = r.xrange('race:france', '-', '+')
puts res11.inspect
# >>> [["1692632086370-0", {"rider"=>"Castilla", "speed"=>"30.2", "position"=>"1", "location_id"=>"1"}],
# ["1692632094485-0", {"rider"=>"Norem", "speed"=>"28.8", "position"=>"3", "location_id"=>"1"}],
# ["1692632102976-0", {"rider"=>"Prickett", "speed"=>"29.7", "position"=>"2", "location_id"=>"1"}],
# ["1692632147973-0", {"rider"=>"Castilla", "speed"=>"29.9", "position"=>"1", "location_id"=>"2"}]]
# >>> [["1692632086370-0", {"rider" => "Castilla", "speed" => "30.2", "position" => "1", "location_id" => "1"}],
# ["1692632094485-0", {"rider" => "Norem", "speed" => "28.8", "position" => "3", "location_id" => "1"}],
# ["1692632102976-0", {"rider" => "Prickett", "speed" => "29.7", "position" => "2", "location_id" => "1"}],
# ["1692632147973-0", {"rider" => "Castilla", "speed" => "29.9", "position" => "1", "location_id" => "2"}]]
# STEP_END

# REMOVE_START
Expand All @@ -199,7 +199,7 @@
# HIDE_END
res12 = r.xrange('race:france', '1692632086369', '1692632086371')
puts res12.inspect
# >>> [["1692632086370-0", {"rider"=>"Castilla", "speed"=>"30.2", "position"=>"1", "location_id"=>"1"}]]
# >>> [["1692632086370-0", {"rider" => "Castilla", "speed" => "30.2", "position" => "1", "location_id" => "1"}]]
# STEP_END

# REMOVE_START
Expand All @@ -217,8 +217,8 @@
# HIDE_END
res13 = r.xrange('race:france', '-', '+', count: 2)
puts res13.inspect
# >>> [["1692632086370-0", {"rider"=>"Castilla", "speed"=>"30.2", "position"=>"1", "location_id"=>"1"}],
# ["1692632094485-0", {"rider"=>"Norem", "speed"=>"28.8", "position"=>"3", "location_id"=>"1"}]]
# >>> [["1692632086370-0", {"rider" => "Castilla", "speed" => "30.2", "position" => "1", "location_id" => "1"}],
# ["1692632094485-0", {"rider" => "Norem", "speed" => "28.8", "position" => "3", "location_id" => "1"}]]
# STEP_END

# REMOVE_START
Expand All @@ -235,8 +235,8 @@
# HIDE_END
res14 = r.xrange('race:france', '(1692632094485-0', '+', count: 2)
puts res14.inspect
# >>> [["1692632102976-0", {"rider"=>"Prickett", "speed"=>"29.7", "position"=>"2", "location_id"=>"1"}],
# ["1692632147973-0", {"rider"=>"Castilla", "speed"=>"29.9", "position"=>"1", "location_id"=>"2"}]]
# >>> [["1692632102976-0", {"rider" => "Prickett", "speed" => "29.7", "position" => "2", "location_id" => "1"}],
# ["1692632147973-0", {"rider" => "Castilla", "speed" => "29.9", "position" => "1", "location_id" => "2"}]]
# STEP_END

# REMOVE_START
Expand All @@ -255,7 +255,7 @@
# STEP_START xrevrange
res16 = r.xrevrange('race:france', '+', '-', count: 1)
puts res16.inspect
# >>> [["1692632147973-0", {"rider"=>"Castilla", "speed"=>"29.9", "position"=>"1", "location_id"=>"2"}]]
# >>> [["1692632147973-0", {"rider" => "Castilla", "speed" => "29.9", "position" => "1", "location_id" => "2"}]]
# STEP_END

# REMOVE_START
Expand All @@ -265,8 +265,8 @@
# STEP_START xread
res17 = r.xread(['race:france'], ['0'], count: 2)
puts res17.inspect
# >>> {"race:france"=>[["1692632086370-0", {"rider"=>"Castilla", "speed"=>"30.2", "position"=>"1", "location_id"=>"1"}],
# ["1692632094485-0", {"rider"=>"Norem", "speed"=>"28.8", "position"=>"3", "location_id"=>"1"}]]}
# >>> {"race:france"=>[["1692632086370-0", {"rider" => "Castilla", "speed" => "30.2", "position" => "1", "location_id" => "1"}],
# ["1692632094485-0", {"rider" => "Norem", "speed" => "28.8", "position" => "3", "location_id" => "1"}]]}
# STEP_END

# REMOVE_START
Expand Down Expand Up @@ -311,7 +311,7 @@

res20 = r.xreadgroup('italy_riders', 'Alice', ['race:italy'], ['>'], count: 1)
puts res20.inspect
# >>> {"race:italy"=>[["1692632639151-0", {"rider"=>"Castilla"}]]}
# >>> {"race:italy"=>[["1692632639151-0", {"rider" => "Castilla"}]]}
# STEP_END

# REMOVE_START
Expand All @@ -321,7 +321,7 @@
# STEP_START xgroup_read_id
res21 = r.xreadgroup('italy_riders', 'Alice', ['race:italy'], ['0'], count: 1)
puts res21.inspect
# >>> {"race:italy"=>[["1692632639151-0", {"rider"=>"Castilla"}]]}
# >>> {"race:italy"=>[["1692632639151-0", {"rider" => "Castilla"}]]}
# STEP_END

# REMOVE_START
Expand All @@ -345,8 +345,8 @@
# STEP_START xgroup_read_bob
res24 = r.xreadgroup('italy_riders', 'Bob', ['race:italy'], ['>'], count: 2)
puts res24.inspect
# >>> {"race:italy"=>[["1692632647899-0", {"rider"=>"Royce"}],
# ["1692632662819-0", {"rider"=>"Sam-Bodden"}]]}
# >>> {"race:italy"=>[["1692632647899-0", {"rider" => "Royce"}],
# ["1692632662819-0", {"rider" => "Sam-Bodden"}]]}
# STEP_END

# REMOVE_START
Expand All @@ -356,7 +356,7 @@
# STEP_START xpending
res25 = r.xpending('race:italy', 'italy_riders')
puts res25.inspect
# >>> {"size"=>2, "min_entry_id"=>"1692632647899-0", "max_entry_id"=>"1692632662819-0", "consumers"=>{"Bob"=>"2"}}
# >>> {"size"=>2, "min_entry_id" => "1692632647899-0", "max_entry_id" => "1692632662819-0", "consumers"=>{"Bob" => "2"}}
# STEP_END

# REMOVE_START
Expand All @@ -377,7 +377,7 @@
# STEP_START xrange_pending
res27 = r.xrange('race:italy', '1692632647899-0', '1692632647899-0')
puts res27.inspect
# >>> [["1692632647899-0", {"rider"=>"Royce"}]]
# >>> [["1692632647899-0", {"rider" => "Royce"}]]
# STEP_END

# REMOVE_START
Expand All @@ -387,7 +387,7 @@
# STEP_START xclaim
res28 = r.xclaim('race:italy', 'italy_riders', 'Alice', 0, '1692632647899-0')
puts res28.inspect
# >>> [["1692632647899-0", {"rider"=>"Royce"}]]
# >>> [["1692632647899-0", {"rider" => "Royce"}]]
# STEP_END

# REMOVE_START
Expand All @@ -397,7 +397,7 @@
# STEP_START xautoclaim
res29 = r.xautoclaim('race:italy', 'italy_riders', 'Alice', 0, '0-0', count: 1)
puts res29.inspect
# >>> {"next"=>"1692632662819-0", "entries"=>[["1692632647899-0", {"rider"=>"Royce"}]]}
# >>> {"next" => "1692632662819-0", "entries"=>[["1692632647899-0", {"rider" => "Royce"}]]}
# STEP_END

# REMOVE_START
Expand All @@ -407,7 +407,7 @@
# STEP_START xautoclaim_cursor
res30 = r.xautoclaim('race:italy', 'italy_riders', 'Lora', 0, res29['next'], count: 1)
puts res30.inspect
# >>> {"next"=>"0-0", "entries"=>[["1692632662819-0", {"rider"=>"Sam-Bodden"}]]}
# >>> {"next" => "0-0", "entries"=>[["1692632662819-0", {"rider" => "Sam-Bodden"}]]}
# STEP_END

# REMOVE_START
Expand Down Expand Up @@ -462,7 +462,7 @@

res35 = r.xrange('race:italy', '-', '+')
puts res35.inspect
# >>> [["1692633198206-0", {"rider"=>"Wood"}], ["1692633208557-0", {"rider"=>"Henshaw"}]]
# >>> [["1692633198206-0", {"rider" => "Wood"}], ["1692633208557-0", {"rider" => "Henshaw"}]]
# STEP_END

# REMOVE_START
Expand Down Expand Up @@ -502,14 +502,14 @@
# HIDE_END
res38 = r.xrange('race:italy', '-', '+', count: 2)
puts res38.inspect
# >>> [["1692633198206-0", {"rider"=>"Wood"}], ["1692633208557-0", {"rider"=>"Henshaw"}]]
# >>> [["1692633198206-0", {"rider" => "Wood"}], ["1692633208557-0", {"rider" => "Henshaw"}]]

res39 = r.xdel('race:italy', '1692633208557-0')
puts res39 # >>> 1

res40 = r.xrange('race:italy', '-', '+', count: 2)
puts res40.inspect
# >>> [["1692633198206-0", {"rider"=>"Wood"}]]
# >>> [["1692633198206-0", {"rider" => "Wood"}]]
# STEP_END

# REMOVE_START
Expand Down
Loading