Redis
What is Redis ?
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries and streams.
Redis คือ open source เพื่อเอาไว้ทำ database , cache และ message broker (ตัวจัดการ pub/sub) ซึ่งมี Datatypes หลายรูปแบบมาก เช่น strings , hashes, list , set ,sorted set ซึ่งมันจะเก็บข้อมูลอยู่ใน RAM ทำให้ไม่ว่าจะ Read , Write ,Update หรือ Delete เร็วมาก
เริ่มใช้งาน Redis กัน
อย่าลืมเข้าไปดาวน์โหลดกันก่อนนะครับ
##start redis
redis-cli
##ทดสอบว่ายังมีการ connect กันอยู่มั้ย
ping
##เซตข้อมูล
SET <constant> <value>
##โชว์ข้อมูล
GET <constant>
##ดูว่ามี constant อยู่มั้ย
EXISTS <constant>
##ลบ constant
DEL <constant>
##ลบทุกอย่าง
FLUSHALL
##เซต key:value
SET <constant>:<key> <value>
##ดูค่า
GET <constant>:<key>
##เซตค่าโดยกำหนดการหมดอายุ
SETEX <constant> <time> <value>
##ดูระยะเวลา
TTL <constant>
LIST
##set list
LPUSH <constant> <value>
##ดูข้อมูล
LRANGE <constant> <number> <number>
##ความยาวของข้อมูล
LLEN <constant>
SET
##เซตข้อมูล
SADD <constant> <value>
##ดูข้อมูล
SMEMBERS <constant>
##ตรวจสอบข้อมูล
SISMEMBER <constant> <value>
##ดูความยาวของข้อมูล
SCARD
HASH
##เซตข้อมูล
HSET <constant> <key> <value>
##ดูข้อมูล
HGET <constant>
##ดูข้อมูลทั้งหมด
HGETALL <constant>
ยังมีข้อมูลอีกหลายรูปแบบให้ศึกษากันนะครับ สามารถเข้าไปดูได้ที่เว็บไซต์ของ redis เองได้เล้ยย
อาจจะสงสัยว่า แล้วไหนบอกว่า ทำอะไรได้เร็วมากมายเหลือเกิน ในบทความนี้แค่บอกก่อนว่า redis คืออะไร แล้วมีคำสั่งอะไรที่เราสามารถเล่นกับมันได้บ้าง ส่วนในการทดสอบว่ามันดียังไง เร็วแค่ไหน จะมีในบทความถัดไปกันนะครับ
Reference :
https://www.youtube.com/watch?v=Hbt56gFj998