Skip to content

Instantly share code, notes, and snippets.

@kuc-arc-f
Created June 25, 2025 05:24
Show Gist options
  • Save kuc-arc-f/e44cbfe749aac474225a00dbf0977188 to your computer and use it in GitHub Desktop.
Save kuc-arc-f/e44cbfe749aac474225a00dbf0977188 to your computer and use it in GitHub Desktop.
node + redis , example-2
{
"name": "redis2_node",
"version": "1.0.0",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"redis": "^5.5.6"
}
}
import { createClient } from "redis";
const start = async function() {
try{
console.time('処理時間');
const client = await createClient()
.on("error", (err) => console.log("Redis Client Error", err))
.connect();
let targetNum = 1;
for (let step = 0; step < 1000; step++) {
targetNum = step + 1;
let setValue = `k:${targetNum}`;
//console.log("setValue=:" + setValue);
await client.set(setValue, "Hello, Redis!");
}
client.destroy();
console.timeEnd('処理時間');
}catch(e){
console.error(e);
}
}
start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment