Last active
March 14, 2025 06:15
-
-
Save up1/b5c674dd98273d7bc2ab3e13c50b941e to your computer and use it in GitHub Desktop.
Redis :: Data structure
This file contains 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
// เพิ่มข้อมูล | |
$LPUSH datas tx1 | |
$LPUSH datas tx2 | |
$LPUSH datas tx3 | |
$LPUSH datas tx4 | |
$LPUSH datas tx5 | |
// ดึงข้อมูล | |
$LRANGE datas 0 -1 | |
1) "tx5" | |
2) "tx4" | |
3) "tx3" | |
4) "tx2" | |
5) "tx1" |
This file contains 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
// เพิ่มข้อมูล | |
$ZADD top-spenders 1000 "customer:01" | |
$ZADD top-spenders 200 "customer:02" | |
$ZADD top-spenders 5000 "customer:03" | |
$ZADD top-spenders 10000 "customer:04" | |
$ZADD top-spenders 8000 "customer:05" | |
// ดึงข้อมูล | |
$ZRANGE top-spenders 0 -1 WITHSCORES REV | |
1) "customer:04" | |
2) "10000" | |
3) "customer:05" | |
4) "8000" | |
5) "customer:03" | |
6) "5000" | |
7) "customer:01" | |
8) "1000" | |
9) "customer:02" | |
10) "200" |
This file contains 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
// เพิ่มข้อมูล | |
$LPUSH datas 1 | |
$LPUSH datas 2 | |
$LPUSH datas 3 | |
$LPUSH datas 4 | |
$LPUSH datas 5 | |
// ดึงข้อมูลทั้งหมด | |
$LRANGE datas 0 -1 | |
1) "5" | |
2) "4" | |
3) "3" | |
4) "2" | |
5) "1" | |
// ทำการ pop ข้อมูลออกตาม FIFO | |
$RPOP datas | |
"1" | |
$RPOP datas | |
"2" | |
$RPOP datas | |
"3" | |
// ดึงข้อมูลทั้งหมด | |
$LRANGE datas 0 -1 | |
1) "5" | |
2) "4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment