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
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,41 @@ console.log(expireRes2); // 1

const expireRes3 = await client.ttl('mykey');
console.log(expireRes3); // 10
// REMOVE_START
assert.equal(expireRes3, 10);
// REMOVE_END

const expireRes4 = await client.set('mykey', 'Hello World');
console.log(expireRes4); // OK

const expireRes5 = await client.ttl('mykey');
console.log(expireRes5); // -1
// REMOVE_START
assert.equal(expireRes5, -1);
// REMOVE_END

const expireRes6 = await client.expire('mykey', 10, "XX");
console.log(expireRes6); // 0
// REMOVE_START
assert.equal(expireRes6, 0)
// REMOVE_END

const expireRes7 = await client.ttl('mykey');
console.log(expireRes7); // -1
// REMOVE_START
assert.equal(expireRes7, -1);
// REMOVE_END

const expireRes8 = await client.expire('mykey', 10, "NX");
console.log(expireRes8); // 1
// REMOVE_START
assert.equal(expireRes8, 1);
// REMOVE_END

const expireRes9 = await client.ttl('mykey');
console.log(expireRes9); // 10
// REMOVE_START
assert.equal(expireRes9, 10);
await client.del('mykey');
// REMOVE_END
// STEP_END
Expand All @@ -87,6 +103,7 @@ console.log(ttlRes2); // 1
const ttlRes3 = await client.ttl('mykey');
console.log(ttlRes3); // 10
// REMOVE_START
assert.equal(ttlRes3, 10);
await client.del('mykey');
// REMOVE_END
// STEP_END
Expand Down Expand Up @@ -155,13 +172,20 @@ console.log(scan3Res2); // 1

const scan3Res3 = await client.type('geokey');
console.log(scan3Res3); // zset
// REMOVE_START
console.assert(scan3Res3 === 'zset');
// REMOVE_END

const scan3Res4 = await client.type('zkey');
console.log(scan3Res4); // zset
// REMOVE_START
console.assert(scan3Res4 === 'zset');
// REMOVE_END

const scan3Res5 = await client.scan('0', { TYPE: 'zset' });
console.log(scan3Res5.keys); // ['zkey', 'geokey']
// REMOVE_START
console.assert(scan3Res5.keys.sort().toString() === ['zkey', 'geokey'].sort().toString());
await client.del(['geokey', 'zkey']);
// REMOVE_END
// STEP_END
Expand All @@ -172,11 +196,18 @@ console.log(scan4Res1); // 2

const scan4Res2 = await client.hScan('myhash', '0');
console.log(scan4Res2.entries); // [{field: 'a', value: '1'}, {field: 'b', value: '2'}]
// REMOVE_START
assert.deepEqual(scan4Res2.entries, [
{ field: 'a', value: '1' },
{ field: 'b', value: '2' }
]);
// REMOVE_END

const scan4Res3 = await client.hScan('myhash', '0', { COUNT: 10 });
const items = scan4Res3.entries.map((item) => item.field)
console.log(items); // ['a', 'b']
// REMOVE_START
assert.deepEqual(items, ['a', 'b'])
await client.del('myhash');
// REMOVE_END
// STEP_END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
print(res)
# >>> ['foobar', 'foo', 'feelsgood']
# REMOVE_START
assert set(res) == {"foo", "foobar", "feelsgood"}
assert sorted(res) == sorted(["foo", "foobar", "feelsgood"])
r.delete("myset")
# REMOVE_END
# STEP_END
Expand Down Expand Up @@ -181,16 +181,22 @@
res = r.type("geokey")
print(res)
# >>> zset
# REMOVE_START
assert res == "zset"
# REMOVE_END

res = r.type("zkey")
print(res)
# >>> zset
# REMOVE_START
assert res == "zset"
# REMOVE_END

cursor, keys = r.scan(cursor=0, _type="zset")
print(keys)
# >>> ['zkey', 'geokey']
# REMOVE_START
assert set(keys) == {"zkey", "geokey"}
assert sorted(keys) == sorted(["zkey", "geokey"])
r.delete("geokey", "zkey")
# REMOVE_END
# STEP_END
Expand All @@ -203,12 +209,18 @@
cursor, keys = r.hscan("myhash", 0)
print(keys)
# >>> {'a': '1', 'b': '2'}
# REMOVE_START
assert keys == {'a': '1', 'b': '2'}
# REMOVE_END

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

# REMOVE_START
r.delete("myhash")
# REMOVE_END
# STEP_END