You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/develop/node/gettingstarted/index-gettingstarted.mdx
+73-57Lines changed: 73 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@ id: index-gettingstarted
3
3
title: Getting Started with Node.js
4
4
sidebar_label: Getting Started
5
5
slug: /develop/node/gettingstarted
6
+
authors: [ajeet, simon]
6
7
---
7
8
8
9
importTabsfrom'@theme/Tabs';
@@ -14,99 +15,114 @@ Find tutorials, examples and technical articles that will help you to develop wi
14
15
15
16
## Introduction
16
17
17
-
Redis is a great database for use with Node.js. Both Redis Node.js share similar type conventions and threading models, which makes for a very predictable development experience. By pairing Node.js & Redis together you can achieve a scalable and productive development platform.
18
+
Redis is a great database for use with Node.js. Both Redis and Node.js share similar type conventions and threading models, which makes for a very predictable development experience. By pairing Node.js and Redis together you can achieve a scalable and productive development platform.
18
19
19
-
Redis Node.js has two primary clients available [node_redis](https://github.com/NodeRedis/node_redis) and [ioredis](https://github.com/luin/ioredis). Both are available through npm. Both clients have pros and cons, but we generally suggest node_redis, as it has wide support for Redis modules, it is easily extensible and widely used. Ioredis has better integrated support for the Redis Enterprise Cluster API, but this is only relevant if you're specifically using [the Cluster API topology](https://redis.com/redis-enterprise/technology/linear-scaling-redis-enterprise/) instead of the more common Proxy topology. Node_redis’ support for the Cluster API is provided by an additional shim, redis-clustr. Node_redis has built-in support for Redis Enterprise features such as [Active Active geo distribution](https://redis.com/redis-enterprise/technology/active-active-geo-distribution/), allowing you to have one database that spans multiple clusters. Node_redis also supports Redis-on-Flash which enables extending your database into Flash SSD storage for warm values and DRAM for hot values. Nodejs redis enables you to integrate such features.
20
+
Redis has two primary Node.js clients which are [node-redis](https://github.com/redis/node-redis) and [ioredis](https://github.com/luin/ioredis). Both are available through npm. We generally suggest using node-redis, as it has wide support for Redis modules, is easily extended, and is widely used.
20
21
21
-
The Node.js community has built many client libraries that you can find [here](https://redis.io/clients#nodejs).
22
-
For your first steps with Node.js and Redis, this article will show how to use the recommended libraries: [ioredis](https://github.com/luin/ioredis) and [node-redis](https://github.com/NodeRedis/node-redis).
22
+
Check out a list of Redis clients that the community has built for Node.js [here](https://redis.io/clients#nodejs).
23
23
24
+
This article shows how to get started with the recommended libraries: [node-redis](https://github.com/redis/node-redis) and [ioredis](https://github.com/luin/ioredis).
24
25
<Tabs
25
-
defaultValue="ioredis"
26
+
defaultValue="node-redis"
26
27
values={[
27
-
{label: 'IO redis', value: 'ioredis'},
28
-
{label: 'Node Redis', value: 'node_redis'},
28
+
{label: 'node-redis', value: 'node-redis'},
29
+
{label: 'ioredis', value: 'ioredis'},
29
30
]}>
30
-
<TabItemvalue="ioredis">
31
+
<TabItemvalue="node-redis">
31
32
32
33
33
-
#### Step 1. Install the ioredis library using `npm` (or `yarn`)
34
+
#### Step 1. Install node-redis using `npm` (or `yarn`)
34
35
35
36
```bash
36
-
npm install ioredis
37
+
npm install redis
37
38
```
38
39
39
40
40
-
#### Step 2. Write your application code
41
+
#### Step 2. Write your Application Code
41
42
42
-
```javascript
43
-
constRedis=require("ioredis");
44
-
constredis=newRedis(6379, "localhost");
43
+
```javascript
44
+
import { createClient } from'redis';
45
45
46
-
redis.set("mykey", "Hello from io-redis!");
47
-
redis.get("mykey", function(err, result){
48
-
if (err) { throw err; }
49
-
50
-
console.log(result);
51
-
});
46
+
asyncfunctionnodeRedisDemo () {
47
+
try {
48
+
constclient=createClient();
49
+
awaitclient.connect();
52
50
53
-
// use the promise instead of callback
54
-
redis.get("mykey").then(function (result) {
55
-
console.log(result);
56
-
});
51
+
awaitclient.set('mykey', 'Hello from node-redis!');
forawait (const { score, value } ofclient.zScanIterator('vehicles')) {
68
+
console.log(`${value} -> ${score}`);
69
+
}
62
70
63
-
Find more information about Redis & io-redis connections in the "[Redis Connect](https://github.com/redis-developer/redis-connect/tree/master/node.js/ioredis)" repository.
71
+
awaitclient.quit();
72
+
} catch (e) {
73
+
console.error(e);
74
+
}
75
+
}
76
+
77
+
nodeRedisDemo();
78
+
```
64
79
65
80
</TabItem>
66
-
<TabItemvalue="node_redis">
81
+
<TabItemvalue="ioredis">
67
82
68
83
69
-
#### Step 1. Install the Redis library using `npm` (or `yarn`)
84
+
#### Step 1. Install ioredis using `npm` (or `yarn`)
Find more information about Redis & node-redis connections in the "[Redis Connect](https://github.com/redis-developer/redis-connect/tree/master/node.js/node-redis)" repository.
Copy file name to clipboardExpand all lines: docs/get-involved/devcember/index-devcember.mdx
+9-6Lines changed: 9 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,11 +21,14 @@ Don't worry if you miss a stream - we'll post them on [YouTube](https://www.yout
21
21
22
22
We'll be on the [Redis channel on Twitch](https://www.twitch.tv/redisinc) and [YouTube](https://www.youtube.com/c/Redisinc/videos) each working day in December… times will vary and we'll update the schedule below daily, revealing each day's topic as we go.
|Wed 1 Dec, 9am UTC |Welcome to DEVcember, Get Started with Redis in the Cloud|<iframesrc="https://www.youtube.com/embed/jf-lwkWUQHg"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"allowfullscreen></iframe>|
27
-
|Thu 2 Dec, 10.30am UTC|Up and Running with RedisInsight |<iframesrc="https://www.youtube.com/embed/S-CXWP50ewM"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"allowfullscreen></iframe>|
28
-
|Fri 3 Dec, Time: TBA |A Beginner's Guide to Redis Lists |[Join us on Twitch](https://www.twitch.tv/redisinc)|
|Wed 1 Dec, 9am UTC |Welcome to DEVcember, Get Started with Redis in the Cloud|<iframesrc="https://www.youtube.com/embed/jf-lwkWUQHg"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"allowfullscreen></iframe>|
27
+
|Thu 2 Dec, 10.30am UTC |Up and Running with RedisInsight |<iframesrc="https://www.youtube.com/embed/S-CXWP50ewM"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"allowfullscreen></iframe>|
28
+
|Fri 3 Dec, 8pm UTC |The Redis List goes on and on! |<iframesrc="https://www.youtube.com/embed/OjoAmWOPk64"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"allowfullscreen></iframe>|
29
+
|Sat 4 / Sun 5 Dec |First weekend hands-on exercise |[Take the challenge on GitHub](https://github.com/redis-developer/devcember/tree/main/challenges/weekend1)|
30
+
|Mon 6 Dec, 4:30pm UTC |TBD |[Follow us on Twitch...](https://twitch.tv/redisinc/)|
31
+
|Tue 7 Dec, 5pm UTC |TBD |[Follow us on Twitch...](https://twitch.tv/redisinc/)|
29
32
30
33
## Meet the Team
31
34
@@ -51,7 +54,7 @@ We'll also feature guest appearances from other members of the Redis developer r
51
54
52
55
Be sure to [follow us on Twitch](https://www.twitch.tv/redisinc) to be notified when we're online! We'd also love to see you on the [Redis Discord](https://discord.gg/nrTwSyUvF2), where there's a dedicated channel for all things DEVcember. This is where you can chat with us throughout the day and get help and information about the fun Redis commands / coding challenges we'll post for you to try on weekends.
53
56
54
-
If you're on Twitter, use hashtag **#RedisDevcember** to join the conversation.
57
+
If you're on Twitter, use hashtag **#RedisDEVcember** to join the conversation.
0 commit comments