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
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Nowadays, it is one of the most popular Redis clients, and more and more people

There are two user roles: contributors and collaborators. Everyone becomes a contributor when they are creating issues, pull requests, or helping to review code.

In the meantime, there is a group of collaborators of ioredis who can not only contribute code but also approve and merge others' pull requests.
In the meantime, there is a group of collaborators of ioredis who cannot only contribute code but also approve and merge others' pull requests.

## Note to collaborators

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,19 +228,19 @@ const Valkey = require("iovalkey");
const valkey = new Valkey();

const processMessage = (message) => {
console.log("Id: %s. Data: %O", message[0], message[1]);
console.log("ID: %s. Data: %O", message[0], message[1]);
};

async function listenForMessage(lastId = "$") {
async function listenForMessage(lastID = "$") {
// `results` is an array, each element of which corresponds to a key.
// Because we only listen to one key (mystream) here, `results` only contains
// a single element. See more: https://valkey.io/commands/xread/
const results = await valkey.xread("block", 0, "STREAMS", "mystream", lastId);
const [key, messages] = results[0]; // `key` equals to "mystream"
const results = await valkey.xread("block", 0, "STREAMS", "mystream", lastID);
const [key, messages] = results[0]; // `key` equals "mystream"

messages.forEach(processMessage);

// Pass the last id of the results to the next round.
// Pass the last ID of the results to the next round.
await listenForMessage(messages[messages.length - 1][0]);
}

Expand Down Expand Up @@ -465,7 +465,7 @@ valkey.myecho("k1", "k2", "a1", "a2", (err, result) => {

// `myechoBuffer` is also defined automatically to return buffers instead of strings:
valkey.myechoBuffer("k1", "k2", "a1", "a2", (err, result) => {
// result[0] equals to Buffer.from('k1');
// result[0] equals Buffer.from('k1');
});

// And of course it works with pipeline:
Expand Down
2 changes: 1 addition & 1 deletion examples/express/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This example demonstrates how to use ioredis in a web application.

The idea is to create a shared Redis instance for the entire application,
intead of using a connection pool or creating a new Redis instance for every
instead of using a connection pool or creating a new Redis instance for every
file or even for every request.

### Install
Expand Down
2 changes: 1 addition & 1 deletion examples/redis_streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const Redis = require("ioredis");
const redis = new Redis();

// you may find this read https://redis.io/topics/streams-intro
// very helpfull as a starter to understand the usescases and the parameters used
// very helpful as a starter to understand the usecases and the parameters used

async function main() {
const channel = "ioredis_channel";
Expand Down
8 changes: 4 additions & 4 deletions examples/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const pub = new Redis();

// Usage 1: As message hub
const processMessage = (message) => {
console.log("Id: %s. Data: %O", message[0], message[1]);
console.log("ID: %s. Data: %O", message[0], message[1]);
};

async function listenForMessage(lastId = "$") {
async function listenForMessage(lastID = "$") {
// `results` is an array, each element of which corresponds to a key.
// Because we only listen to one key (mystream) here, `results` only contains
// a single element. See more: https://redis.io/commands/xread#return-value
const results = await sub.xread("BLOCK", 0, "STREAMS", "user-stream", lastId);
const [key, messages] = results[0]; // `key` equals to "user-stream"
const results = await sub.xread("BLOCK", 0, "STREAMS", "user-stream", lastID);
const [key, messages] = results[0]; // `key` equals "user-stream"

messages.forEach(processMessage);

Expand Down
2 changes: 1 addition & 1 deletion examples/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const redis = new Redis();
async function main() {
const user = {
name: "Bob",
// The value of a Redis key can not be a number.
// The value of a Redis key cannot be a number.
// We can write `age: 20` here but ioredis will convert it to a string anyway.
age: "20",
description: "I am a programmer",
Expand Down
2 changes: 1 addition & 1 deletion lib/DataHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default class DataHandler {
switch (replyType) {
case "message":
if (this.redis.listeners("message").length > 0) {
// Check if there're listeners to avoid unnecessary `toString()`.
// Check if there are listeners to avoid unnecessary `toString()`.
this.redis.emit(
"message",
reply[1].toString(),
Expand Down
2 changes: 1 addition & 1 deletion lib/cluster/ClusterSubscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default class ClusterSubscriber {

// The node we lost connection to may not come back up in a
// reasonable amount of time (e.g. a slave that's taken down
// for maintainence), we could potentially miss many published
// for maintenance), we could potentially miss many published
// messages so we should reconnect as quickly as possible, to
// a different node if needed.
this.subscriber.once("end", this.onSubscriberEnd);
Expand Down
4 changes: 2 additions & 2 deletions lib/cluster/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Cluster extends Commander {
/**
* Every time Cluster#connect() is called, this value will be
* auto-incrementing. The purpose of this value is used for
* discarding previous connect attampts when creating a new
* discarding previous connect attempts when creating a new
* connection.
*/
private connectionEpoch = 0;
Expand Down Expand Up @@ -1013,7 +1013,7 @@ class Cluster extends Commander {
* Normalize startup nodes, and resolving hostnames to IPs.
*
* This process happens every time when #connect() is called since
* #startupNodes and DNS records may chanage.
* #startupNodes and DNS records may change.
*/
private async resolveStartupNodeHostnames(): Promise<RedisOptions[]> {
if (!Array.isArray(this.startupNodes) || this.startupNodes.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion lib/redis/RedisOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export interface CommonRedisOptions extends CommanderOptions {
*
* By default, if the connection to Redis server has not been established, commands are added to a queue
* and are executed once the connection is "ready" (when `enableReadyCheck` is true, "ready" means
* the Redis server has loaded the database from disk, otherwise means the connection to the Redis
* the Redis server has loaded the database from disk; otherwise, means the connection to the Redis
* server has been established). If this option is false, when execute the command when the connection
* isn't ready, an error will be returned.
*
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/RedisCommander.ts

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is auto-generated, these changes will be overwrite.
needs to port the spelling fixes to https://github.com/valkey-io/valkey/tree/57b176169d2c869d14dc4908674ffbb8b28b39cc/src/commands
@jsoref can you fix it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
Expand Up @@ -8978,7 +8978,7 @@ interface RedisCommander<Context extends ClientContext = { type: "default" }> {
/**
* Synchronously saves the database(s) to disk and shuts down the server.
* - _group_: server
* - _complexity_: O(N) when saving, where N is the total number of keys in all databases when saving data, otherwise O(1)
* - _complexity_: O(N) when saving, where N is the total number of keys in all databases when saving data; otherwise, O(1)
* - _since_: 1.0.0
*/
shutdown(callback?: Callback<"OK">): Result<"OK", Context>;
Expand Down Expand Up @@ -10009,7 +10009,7 @@ interface RedisCommander<Context extends ClientContext = { type: "default" }> {
/**
* Returns one or more random members from a set after removing them. Deletes the set if the last member was popped.
* - _group_: set
* - _complexity_: Without the count argument O(1), otherwise O(N) where N is the value of the passed count.
* - _complexity_: Without the count argument O(1); otherwise, O(N) where N is the value of the passed count.
* - _since_: 1.0.0
*/
spop(
Expand Down Expand Up @@ -10046,7 +10046,7 @@ interface RedisCommander<Context extends ClientContext = { type: "default" }> {
/**
* Get one or multiple random members from a set
* - _group_: set
* - _complexity_: Without the count argument O(1), otherwise O(N) where N is the absolute value of the passed count.
* - _complexity_: Without the count argument O(1); otherwise, O(N) where N is the absolute value of the passed count.
* - _since_: 1.0.0
*/
srandmember(
Expand Down
2 changes: 1 addition & 1 deletion test/functional/cluster/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ describe("cluster", () => {
});

describe("#nodes()", () => {
it("should return the corrent nodes", (done) => {
it("should return the current nodes", (done) => {
const slotTable = [
[0, 16381, ["127.0.0.1", 30001], ["127.0.0.1", 30003]],
[16382, 16383, ["127.0.0.1", 30002]],
Expand Down
6 changes: 3 additions & 3 deletions test/functional/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe("connection", function () {
retryStrategy: null,
});
let isReady = false;
let timedoutCalled = false;
let timeoutCalled = false;

// TODO: use spy
sinon
Expand All @@ -117,14 +117,14 @@ describe("connection", function () {
if (!isReady) {
isReady = true;
} else {
timedoutCalled = true;
timeoutCalled = true;
}
return;
}

setTimeout(() => {
callback();
expect(timedoutCalled).to.eql(false);
expect(timeoutCalled).to.eql(false);
redis.disconnect();
done();
}, timeout);
Expand Down
10 changes: 5 additions & 5 deletions test/functional/lazy_connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ describe("lazy connect", () => {
done();
});
const cluster = new Cluster([], { lazyConnect: true });
const pipline = new Pipeline(cluster);
pipline.get("fool1").exec(() => {});
const pipeline = new Pipeline(cluster);
pipeline.get("fool1").exec(() => {});
});

it("should call connect when transction exec", (done) => {
it("should call connect when transaction exec", (done) => {
const stub = sinon.stub(Cluster.prototype, "connect").callsFake(() => {
stub.restore();
done();
Expand All @@ -74,7 +74,7 @@ describe("lazy connect", () => {
.exec(() => {});
});

it('should quit before "close" being emited', (done) => {
it('should quit before "close" being emitted', (done) => {
const stub = sinon
.stub(Cluster.prototype, "connect")
.throws(new Error("`connect` should not be called"));
Expand All @@ -89,7 +89,7 @@ describe("lazy connect", () => {
});
});

it('should disconnect before "close" being emited', (done) => {
it('should disconnect before "close" being emitted', (done) => {
const stub = sinon
.stub(Cluster.prototype, "connect")
.throws(new Error("`connect` should not be called"));
Expand Down
2 changes: 1 addition & 1 deletion test/functional/reconnect_on_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe("reconnectOnError", () => {
});
});

it("should select the currect database", (done) => {
it("should select the correct database", (done) => {
const redis = new Redis({
reconnectOnError: () => {
redis.select(3);
Expand Down
22 changes: 11 additions & 11 deletions test/functional/scripting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe("scripting", () => {
]);
});

it("should try to use EVALSHA and fallback to EVAL if fails", async () => {
it("should try to use EVALSHA and fall back to EVAL if fails", async () => {
const redis = new Redis();

redis.defineCommand("test", {
Expand All @@ -203,9 +203,9 @@ describe("scripting", () => {
await redis.test("bar");
});

const expectedComands = ["evalsha", "eval", "get", "evalsha", "get"];
const expectedCommands = ["evalsha", "eval", "get", "evalsha", "get"];
expect(commands.map((c) => c[0].toLowerCase())).to.have.members(
expectedComands
expectedCommands
);
});

Expand All @@ -230,14 +230,14 @@ describe("scripting", () => {
return redis.pipeline().testGet("foo").testSet("foo").get("foo").exec();
});

const expectedComands = ["evalsha", "get", "eval", "set", "get"];
const expectedCommands = ["evalsha", "get", "eval", "set", "get"];

expect(commands.map((c) => c[0].toLowerCase())).to.have.members(
expectedComands
expectedCommands
);
});

it("does not fallback to EVAL in regular transaction", async () => {
it("does not fall back to EVAL in regular transaction", async () => {
const redis = new Redis();

redis.defineCommand("test", {
Expand All @@ -259,13 +259,13 @@ describe("scripting", () => {
});
spy.restore();
expect(spy.callCount).to.equal(4);
const expectedComands = ["multi", "evalsha", "evalsha", "exec"];
const expectedCommands = ["multi", "evalsha", "evalsha", "exec"];
expect(commands.map((c) => c[0].toLowerCase())).to.have.members(
expectedComands
expectedCommands
);
});

it("does not fallback to EVAL in manual transaction", async () => {
it("does not fall back to EVAL in manual transaction", async () => {
const redis = new Redis();

redis.defineCommand("test", {
Expand All @@ -285,9 +285,9 @@ describe("scripting", () => {
});
spy.restore();
expect(spy.callCount).to.equal(4);
const expectedComands = ["multi", "evalsha", "evalsha", "exec"];
const expectedCommands = ["multi", "evalsha", "evalsha", "exec"];
expect(commands.map((c) => c[0].toLowerCase())).to.have.members(
expectedComands
expectedCommands
);
});

Expand Down
2 changes: 1 addition & 1 deletion test/functional/string_numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("stringNumbers", () => {
expect(await redis.incr("foo")).to.equal("9007199254740993");
expect(await redis.incr("foo")).to.equal("9007199254740994");

// also works for small interger
// also works for small integer
await redis.set("foo", 123);
expect(await redis.incr("foo")).to.equal("124");

Expand Down
Loading