Skip to content

Commit ae98015

Browse files
Merge pull request #57 from RedisInsight/main
Releasing latest changes
2 parents 12c17f8 + 3ea3450 commit ae98015

8 files changed

+475
-23
lines changed

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,19 @@ redis:[pipeline=8;mode=raw;results=single;]
214214
```
215215
### Links configuration
216216

217+
#### Reference other tutorials
218+
You can reference other tutorial pages.
219+
To do this, use the markdown syntax described below and specify the ID of the tutorial you want to link to:
220+
```
221+
[{text}](redisinsight:_?tutorialId={tutorialId})
222+
```
223+
224+
For example:
225+
```
226+
[Create JSON Documents](redisinsight:_?tutorialId=ds-json-create)
227+
```
228+
229+
217230
#### Internal links
218231
You can insert links that lead to a specific page inside Redis Insight. The syntax for these links is following:
219232
```
@@ -242,7 +255,6 @@ The full list of pages:
242255
| Functions | triggered-functions/functions |
243256
| Settings | settings |
244257

245-
246258
#### Create a free Cloud database link
247259

248260
Also, there is a possibility to insert link which opens Create Free Database dialog inside Redis Insight

src/manifest.json

+27
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77
"initialIsOpen": true
88
},
99
"children": [
10+
{
11+
"type": "internal-link",
12+
"id": "redis_use_cases",
13+
"label": "Redis Use Cases",
14+
"summary": "A collection of several common use cases for Redis.",
15+
"args": {
16+
"initialIsOpen": true,
17+
"path": "/uc/intro.md"
18+
}
19+
},
1020
{
1121
"type": "group",
1222
"id": "ds",
@@ -405,6 +415,15 @@
405415
"initialIsOpen": false
406416
},
407417
"children": [
418+
{
419+
"type": "internal-link",
420+
"id": "vss-intro",
421+
"label": "Introduction",
422+
"summary": "Understand how to use Redis as a vector database.",
423+
"args": {
424+
"path": "/vss/intro.md"
425+
}
426+
},
408427
{
409428
"type": "internal-link",
410429
"id": "vss-vectors-basic",
@@ -420,6 +439,14 @@
420439
"args": {
421440
"path": "/vss/vectors-adv-hash.md"
422441
}
442+
},
443+
{
444+
"type": "internal-link",
445+
"id": "vss-learn-more",
446+
"label": "Learn more",
447+
"args": {
448+
"path": "/vss/learn-more.md"
449+
}
423450
}
424451
]
425452
}

src/uc/intro.md

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
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.
2+
3+
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.
4+
5+
```redis-upload:[/uc/sample_data.txt] Upload Sample Data
6+
```
7+
8+
### Matchmaking
9+
10+
Redis serves as a powerful document store that is well-suited for matchmaking use cases. For instance, consider a bike shop where you need to pair shoppers with bikes based on their preferences and budget.
11+
12+
You can store your bike inventory using the JSON data structure, where bikes have attributes such as type (e.g., mountain, road, electric), condition (new or used), price, etc.
13+
14+
```redis:[run_confirmation=true] Add a bike as JSON
15+
// Add a bike as JSON
16+
JSON.SET sample_bicycle:2048 $ '{
17+
"model": "Ranger",
18+
"brand": "TrailBlazer",
19+
"price": 450,
20+
"type": "Mountain",
21+
"specs": {
22+
"material": "carbon",
23+
"weight": 12
24+
},
25+
"description": "The Ranger is designed for rugged trails and adventurous rides!",
26+
"addons": [
27+
"water bottle holder",
28+
"rear rack"
29+
],
30+
"helmet_included": false
31+
}'
32+
```
33+
34+
In Redis, you can easily index these attributes and perform complex queries efficiently.
35+
36+
```redis:[run_confirmation=true] Create a bike index
37+
// Create a secondary index of your bike data
38+
FT.CREATE idx:smpl_bicycle
39+
ON JSON
40+
PREFIX 1 sample_bicycle:
41+
SCHEMA
42+
$.brand AS brand TEXT
43+
$.model AS model TEXT
44+
$.description AS description TEXT
45+
$.price AS price NUMERIC
46+
$.condition AS condition TAG SEPARATOR ,
47+
$.type AS type TAG
48+
$.helmet_included AS helmet_included TAG
49+
$.specs.material AS material TAG
50+
$.specs.weight AS weight NUMERIC
51+
```
52+
53+
You can then easily match a user to their preferred type of bike within a requested price bracket.
54+
55+
```redis:[run_confirmation=true] Search for a match
56+
// 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
86+
```
87+
88+
### Session store
89+
90+
Redis shines as a session store, offering speed and scalability for web applications. Using commands like HSET to store session data as hashes and HGET to retrieve it, Redis ensures rapid access to user sessions.
91+
92+
```redis:[run_confirmation=true] Create a session hash with expiration
93+
// 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"
95+
96+
// Set an expiration time for the new session entry
97+
EXPIRE sample_session:074529275 7344000
98+
```
99+
100+
```redis:[run_confirmation=true] Retrieve a session
101+
// Retrieve an existing session
102+
HGETALL sample_session:074529275
103+
```
104+
105+
### Job queue
106+
107+
In many applications, tasks need to be processed asynchronously, such as maintaining a waiting list for a helpdesk where incoming support tickets are queued for processing. A job queue helps manage these tasks efficiently. In Redis, a [job queue](https://redis.io/glossary/redis-queue/) can be implemented using the List data structure. When a new task needs to be queued, it is added to the left end of the list (using the LPUSH command). When a worker is ready to process a task, it dequeues it from the right end of the list (using the RPOP command).
108+
109+
110+
```redis:[run_confirmation=true] Create a job ticket
111+
// 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"
113+
```
114+
```redis:[run_confirmation=true] Enqueue job
115+
// Enqueue the new job to the waiting list
116+
LPUSH sample_jobQueue:waitingList sample_jobQueue:ticket:199
117+
```
118+
```redis:[run_confirmation=true] Show all jobs
119+
// Show the full list of jobs
120+
LRANGE sample_jobQueue:waitingList 0 -1
121+
```
122+
```redis:[run_confirmation=true] Dequeue a job
123+
// Dequeue a job from the list
124+
RPOP sample_jobQueue:waitingList
125+
```
126+
127+
### Leaderboard
128+
129+
[Leaderboards](https://redis.io/solutions/leaderboards/) are crucial for gaming applications to display rankings based on scores. Sorted Sets in Redis are perfect for this purpose due to their ability to store elements with associated scores, which can be easily queried and sorted.
130+
131+
```redis:[run_confirmation=true] Create a leaderboard score
132+
// Add a new score to leaderboard
133+
ZADD sample_leaderboard:tetris 670000 "user100"
134+
```
135+
136+
```redis:[run_confirmation=true] Get users with scores
137+
// Get the top 5 users on the leaderboard, with scores
138+
ZRANGE sample_leaderboard:tetris 0 4 REV WITHSCORES
139+
```

0 commit comments

Comments
 (0)