@@ -13,7 +13,7 @@ You can store your bike inventory using the JSON data structure, where bikes hav
13
13
14
14
``` redis:[run_confirmation=true] Add a bike as JSON
15
15
// Add a bike as JSON
16
- JSON.SET bicycle :2048 $ '{
16
+ JSON.SET sample_bicycle :2048 $ '{
17
17
"model": "Ranger",
18
18
"brand": "TrailBlazer",
19
19
"price": 450,
@@ -35,9 +35,9 @@ In Redis, you can easily index these attributes and perform complex queries effi
35
35
36
36
``` redis:[run_confirmation=true] Create a bike index
37
37
// Create a secondary index of your bike data
38
- FT.CREATE idx:bicycle
38
+ FT.CREATE idx:smpl_bicycle
39
39
ON JSON
40
- PREFIX 1 bicycle :
40
+ PREFIX 1 sample_bicycle :
41
41
SCHEMA
42
42
$.brand AS brand TEXT
43
43
$.model AS model TEXT
@@ -54,7 +54,7 @@ You can then easily match a user to their preferred type of bike within a reques
54
54
55
55
``` redis:[run_confirmation=true] Search for a match
56
56
// Match leisure bikes within a price of 200 and 300
57
- FT.SEARCH idx:bicycle "@type:{mountain} @price:[400 450]" RETURN 4 brand model type price
57
+ FT.SEARCH idx:smpl_bicycle "@type:{mountain} @price:[400 450]" RETURN 4 brand model type price
58
58
```
59
59
60
60
### Session store
@@ -63,15 +63,15 @@ Redis shines as a session store, offering speed and scalability for web applicat
63
63
64
64
``` redis:[run_confirmation=true] Create a session hash with expiration
65
65
// Store new session
66
- HSET session :074529275 user_id 7254 username gabe_jones email gabe@example.com last_activity "2024-06-01 10:24:00"
66
+ HSET sample_session :074529275 user_id 7254 username gabe_jones email gabe@example.com last_activity "2024-06-01 10:24:00"
67
67
68
68
// Set an expiration time for the new session entry
69
- EXPIRE session :074529275 7344000
69
+ EXPIRE sample_session :074529275 7344000
70
70
```
71
71
72
72
``` redis:[run_confirmation=true] Retrieve a session
73
73
// Retrieve an existing session
74
- HGETALL session :074529275
74
+ HGETALL sample_session :074529275
75
75
```
76
76
77
77
### Job queue
@@ -81,19 +81,19 @@ In many applications, tasks need to be processed asynchronously, such as maintai
81
81
82
82
``` redis:[run_confirmation=true] Create a job ticket
83
83
// Create a new job as a Hash
84
- HSET jobQueue :ticket:199 id 199 user_id 723 description "Unable to access console" priority "High" created_at "2024-04-20T12:00:00Z"
84
+ HSET sample_jobQueue :ticket:199 id 199 user_id 723 description "Unable to access console" priority "High" created_at "2024-04-20T12:00:00Z"
85
85
```
86
86
``` redis:[run_confirmation=true] Enqueue job
87
87
// Enqueue the new job to the waiting list
88
- LPUSH jobQueue :waitingList jobQueue:ticket:199
88
+ LPUSH sample_jobQueue :waitingList jobQueue:ticket:199
89
89
```
90
90
``` redis:[run_confirmation=true] Show all jobs
91
91
// Show the full list of jobs
92
- LRANGE jobQueue :waitingList 0 -1
92
+ LRANGE sample_jobQueue :waitingList 0 -1
93
93
```
94
94
``` redis:[run_confirmation=true] Dequeue a job
95
95
// Dequeue a job from the list
96
- RPOP jobQueue :waitingList
96
+ RPOP sample_jobQueue :waitingList
97
97
```
98
98
99
99
### Leaderboard
@@ -102,10 +102,10 @@ RPOP jobQueue:waitingList
102
102
103
103
``` redis:[run_confirmation=true] Create a leaderboard score
104
104
// Add a new score to leaderboard
105
- ZADD leaderboard :tetris 670000 "user100"
105
+ ZADD sample_leaderboard :tetris 670000 "user100"
106
106
```
107
107
108
108
``` redis:[run_confirmation=true] Get users with scores
109
109
// Get the top 5 users on the leaderboard, with scores
110
- ZRANGE leaderboard :tetris 0 4 REV WITHSCORES
110
+ ZRANGE sample_leaderboard :tetris 0 4 REV WITHSCORES
111
111
```
0 commit comments