Skip to content

Commit 8a921cf

Browse files
authored
Merge pull request #59 from RedisInsight/main
update uc
2 parents ae98015 + 506abe7 commit 8a921cf

File tree

2 files changed

+197
-276
lines changed

2 files changed

+197
-276
lines changed

src/uc/intro.md

+14-42
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**Redis** is a powerful in-memory data structure store that can be used for various use cases due to its speed, simplicity, and versatility. In this tutorial, we'll explore several common use cases: matchmaking, location-based search, job queue, leaderboard, and session store.
1+
**Redis** is a powerful in-memory data structure store that can be used for various use cases due to its speed, simplicity, and versatility. In this tutorial, we'll explore several common use cases: matchmaking, job queue, leaderboard, and session store.
22

33
If you haven't done so already, you can upload the sample data related to this tutorial by clicking the button below. You will also need support for [JSON](https://redis.io/docs/latest/develop/data-types/json/) and [Search & query](https://redis.io/docs/latest/develop/interact/search-and-query/) in your database to take advantage of this tutorial fully.
44

@@ -13,7 +13,7 @@ You can store your bike inventory using the JSON data structure, where bikes hav
1313

1414
```redis:[run_confirmation=true] Add a bike as JSON
1515
// Add a bike as JSON
16-
JSON.SET sample_bicycle:2048 $ '{
16+
JSON.SET bicycle:2048 $ '{
1717
"model": "Ranger",
1818
"brand": "TrailBlazer",
1919
"price": 450,
@@ -35,9 +35,9 @@ In Redis, you can easily index these attributes and perform complex queries effi
3535

3636
```redis:[run_confirmation=true] Create a bike index
3737
// Create a secondary index of your bike data
38-
FT.CREATE idx:smpl_bicycle
38+
FT.CREATE idx:bicycle
3939
ON JSON
40-
PREFIX 1 sample_bicycle:
40+
PREFIX 1 bicycle:
4141
SCHEMA
4242
$.brand AS brand TEXT
4343
$.model AS model TEXT
@@ -54,35 +54,7 @@ You can then easily match a user to their preferred type of bike within a reques
5454

5555
```redis:[run_confirmation=true] Search for a match
5656
// Match leisure bikes within a price of 200 and 300
57-
FT.SEARCH idx:smpl_bicycle "@type:{mountain} @price:[400 450]" RETURN 4 brand model type price
58-
```
59-
60-
### Location-based search
61-
62-
Location-based search involves finding and retrieving data that is relevant to a specific geographic location. Redis can be used to power location-based search applications by storing and indexing geospatial data, such as latitude and longitude coordinates, and providing fast and efficient search capabilities
63-
64-
```redis:[run_confirmation=true] Add a restaurant
65-
// Add a restaurant as JSON
66-
JSON.SET sample_restaurant:341 $ '{
67-
"name": "Zen Galushca",
68-
"cuisine": "Japanese",
69-
"location": "-98.1221,30.8232"
70-
}'
71-
```
72-
```redis:[run_confirmation=true] Create a restaurant index
73-
//Create an index of your restaurant data
74-
FT.CREATE "idx:smpl_restaurant"
75-
ON JSON
76-
PREFIX 1 "sample_restaurant:"
77-
SCHEMA
78-
"$.cuisine" AS "cuisine" TAG
79-
"$.name" AS "restaurant_name" TEXT
80-
"$.location" AS "location" GEO
81-
```
82-
83-
```redis:[run_confirmation=true] Search for a restaurant
84-
// Find a Japanese restaurant within a 50 mile radius
85-
FT.SEARCH idx:smpl_restaurant "@cuisine:{japanese} @location:[-98.1179,30.671 50 mi]" RETURN 2 restaurant_name location
57+
FT.SEARCH idx:bicycle "@type:{mountain} @price:[400 450]" RETURN 4 brand model type price
8658
```
8759

8860
### Session store
@@ -91,15 +63,15 @@ Redis shines as a session store, offering speed and scalability for web applicat
9163

9264
```redis:[run_confirmation=true] Create a session hash with expiration
9365
// Store new session
94-
HSET sample_session:074529275 user_id 7254 username gabe_jones email [email protected] last_activity "2024-06-01 10:24:00"
66+
HSET session:074529275 user_id 7254 username gabe_jones email [email protected] last_activity "2024-06-01 10:24:00"
9567
9668
// Set an expiration time for the new session entry
97-
EXPIRE sample_session:074529275 7344000
69+
EXPIRE session:074529275 7344000
9870
```
9971

10072
```redis:[run_confirmation=true] Retrieve a session
10173
// Retrieve an existing session
102-
HGETALL sample_session:074529275
74+
HGETALL session:074529275
10375
```
10476

10577
### Job queue
@@ -109,19 +81,19 @@ In many applications, tasks need to be processed asynchronously, such as maintai
10981

11082
```redis:[run_confirmation=true] Create a job ticket
11183
// Create a new job as a Hash
112-
HSET sample_jobQueue:ticket:199 id 199 user_id 723 description "Unable to access console" priority "High" created_at "2024-04-20T12:00:00Z"
84+
HSET jobQueue:ticket:199 id 199 user_id 723 description "Unable to access console" priority "High" created_at "2024-04-20T12:00:00Z"
11385
```
11486
```redis:[run_confirmation=true] Enqueue job
11587
// Enqueue the new job to the waiting list
116-
LPUSH sample_jobQueue:waitingList sample_jobQueue:ticket:199
88+
LPUSH jobQueue:waitingList jobQueue:ticket:199
11789
```
11890
```redis:[run_confirmation=true] Show all jobs
11991
// Show the full list of jobs
120-
LRANGE sample_jobQueue:waitingList 0 -1
92+
LRANGE jobQueue:waitingList 0 -1
12193
```
12294
```redis:[run_confirmation=true] Dequeue a job
12395
// Dequeue a job from the list
124-
RPOP sample_jobQueue:waitingList
96+
RPOP jobQueue:waitingList
12597
```
12698

12799
### Leaderboard
@@ -130,10 +102,10 @@ RPOP sample_jobQueue:waitingList
130102

131103
```redis:[run_confirmation=true] Create a leaderboard score
132104
// Add a new score to leaderboard
133-
ZADD sample_leaderboard:tetris 670000 "user100"
105+
ZADD leaderboard:tetris 670000 "user100"
134106
```
135107

136108
```redis:[run_confirmation=true] Get users with scores
137109
// Get the top 5 users on the leaderboard, with scores
138-
ZRANGE sample_leaderboard:tetris 0 4 REV WITHSCORES
110+
ZRANGE leaderboard:tetris 0 4 REV WITHSCORES
139111
```

0 commit comments

Comments
 (0)