Installing Redis with homebrew can reduce the amount of installation and configuration effort.
- Detects if the homebrew is installed
Brew-v
Brew Install Redis
- Message after installation is complete
To has launchd start Redis at login:
Ln-sfv/usr/local/opt/redis/*.plist ~/library/launchagents
Then-to-load Redis now:
Launchctl Load ~/library/launchagents/homebrew.mxcl.redis.plist
Or, if you don ' t want/need launchctl, you can just run:
Redis-server/usr/local/etc/redis.conf
$ ln-sfv/usr/local/opt/redis/*.plist ~/library/launchagents
- Starting Redis server with Launchctl
$ launchctl Load ~/library/launchagents/homebrew.mxcl.redis.plist
- To start Redis server using a configuration file
$ redis-server/usr/local/etc/redis.conf
Redis commands are used to perform operations on the Redis service.
A Redis client is required to execute commands on the Redis service. The Redis client is in the Redis installation package that we downloaded earlier.
- To start the Redis client:
In the above example we connect to the local Redis service and perform a PING command that detects whether the Redis service is started.
- Execute command on remote service
$redis -cli -h 127.0. 0.1 -p 6379-a "mypass" Redis 127.0 0.1:6379> Redis Span class= "lit" >127.0. 0.1:6379> PING PONG
============
View all Keys
127.0.0.1:6379> Keys ' * * '
(empty list or set)
Assigns a value to a string named key in the database
127.0.0.1:6379> Set name Yihua
Ok
Returns the value of a string named key in the database
127.0.0.1:6379> Get Name
"Yihua"
127.0.0.1:6379>
============
- Stop the Redis server from booting
$ launchctl Unload ~/library/launchagents/homebrew.mxcl.redis.plist
- Location of Redis configuration files
/usr/local/etc/redis.conf
REDIS-CLI shutdown
- Uninstalling Redis and its files
$ brew Uninstall Redis
$ RM ~/library/launchagents/homebrew.mxcl.redis.plist
- Test if Redis server is started
$ redis-cli Ping
Installing and configuring Redis under Mac