Installation and test of redis on MacOS


About redis

Redis is a key value database with high performance and free of charge and BSD protocol.

Redis runs in memory and supports data persistence. It can save the data in memory on the disk. It can be loaded again for use when restarting.

Redis not only supports simple key value data, but also provides storage of list, set, Zset, hash and other data structures.

Why Redis?

As a key value database, redis:

High performance

Redis can read 110000 times / s and write 81000 times / s

Rich data types


All operations of redis are atomic

Download redis on MacOS

$ brew install redis

Terminal output

Configure redis

Redis default configuration file after installation redis.conf Located at / usr / local / etc

At the same time, redis- sentinel.conf It’s here, too.

How to configure redis on the official website:

Redis is able to start without a configuration file using a built-in default configuration, however this setup is only recommended for testing and development purposes.

The proper way to configure Redis is by providing a Redis configuration file, usually called redis.conf.

According to the above, if no configuration file is specified during startup, redis will use the built-in default configuration in the program. However, it is only considered to use the built-in default configuration in the development and testing phases. It is better to provide a configuration file for the formal environment, and it is generally named as redis.conf

Use the cat command to view redis.conf :

$ cat /usr/local/etc/redis.conf

Start redis

$ redis-server /usr/local/etc/redis.conf

It can be seen that the redis server is successfully started and is listening for the network connection of port 6379.

Note: using the command $redis server can also be started. At this time, no configuration file will be loaded. The default configuration built-in in in the program is used

If you want to check whether the redis server is started, you need to reopen a terminal window and enter the command

$ redis-cli ping

If output


Indicates that the server is working normally.

Close redis

Method 1

Use Ctrl + C in the window where the start command is executed

Method 2

Execute $redis cli shutdown in another terminal window


If redis is closed, it should be displayed in the window where the start command is executed

Or we can execute $redis cli Ping in another terminal window


Could not connect to Redis at Connection refused

This indicates that redis is indeed closed

The above installation and test operation of redis on MacOS is the whole content shared by Xiaobian. I hope to give you a reference, and I hope you can support developeppaer more.