Created
June 25, 2025 05:24
-
-
Save kuc-arc-f/e44cbfe749aac474225a00dbf0977188 to your computer and use it in GitHub Desktop.
node + redis , example-2
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
| { | |
| "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" | |
| } | |
| } |
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
| 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