Getting started overview
1. What is it?
Redis: Remote Dictionary Server (remote dictionary server). It is completely open source and free, written in C language, a high-performance KV distributed memory database that complies with the BSD protocol, and a NoSql database that runs on memory and supports persistence. Is currently one of the most popular NoSql databases.
- Redis supports data persistence. The data in the memory can be stored on the disk, and it can be loaded again for use when restarting.
- Redis not only supports simple KV type data, but also provides storage for list, set, zset, hash and other data structures
- Redis supports data backup, that is, data backup in master-salve mode
2. What can you do
- Memory storage and persistence: Redis supports asynchronous writing of data in memory to the hard disk without affecting the continued service.
- The operation of fetching the latest N data, such as: you can put the IDs of the latest 10 comments in the redis list collection.
- The simulation is similar to HTTPSession, which requires setting the expiration time.
- Publish and subscribe message system
- Timer, counter
3. Where to go
Download redis-3.0.4.tar.gz to the /opt directory of the server
After decompression, a folder appears: redis-3.0.4
Execute the make command in the redis-3.0.4 directory (you can use it to
gcc -vcheck whether gcc is installed, if not, use yum to install it)
If you report this error:
Redis related commands are stored in /usr/local/bin
Modify redis.conf under /opt/redis-3.0.4/ (remember to backup), and set the daemon to yes
Then use the client to enter:
redis-cli -p 6379
Exit the client: enter exit in the client; exit redis: enter shutdown in the client
Miscellaneous basic knowledge after startup
The redis commands are as follows:
redis-benchmark can be used to measure performance~~
- There are 16 databases by default, which can be modified in the redis.conf file. Use in the client
select [n]to switch databases (the index of the first database is 0)
dbsize: View the number of keys in the current database.
keys *View what keys the current database has
flushdb: Clear the current library.
flushallEmpty all libraries
- Unified password management, all 16 libraries have the same password, either all are ok, or none of them can be connected
- Redis indexes start from 0
- Why is the default port 6379? Merz, Italian female singer