This is the third day of my participation in the November Gwen Challenge. Check out the details: the last Gwen Challenge 2021

Hello everybody! I’m a mistress. I’m here to write more.

Today I’m going to write about some of the core configuration of Redis6 and the naming conventions for keys. Reorganize what you learned before haha.

Redis6 Server Settings

  1. Daemonize (whether can configure the background) : recommend YES | the default value is No
  1. Bind (binding host address) : 0.0.0.0 address is not limit | bind the host address 127.0.0.1 binding | configuration of multiple address in the address

Separate them with Spaces

  1. Port (default listening port) : the default is 6379
  2. Requirepass (Connection password)
  1. Dbfilename (save database filename) Default value dump.rdb
  2. Dir (database storage path) The default value is./
  1. Save (configure redis persistence mechanism)

Redis6 Log configuration

  1. Loglevel (set server specify logging level) : the debug | verbose | notice | warning
  2. Logfile: indicates the port number. Log

Note: Set the log level to verbose and the production environment to notice, simplifying log output and reducing log I/O frequency.

Redis6 Client Settings

  1. Maxclients 0 (Sets the maximum number of client connections at a time. Default is unlimited. When the client connection reaches the set value, Redis closes the new connection.
  2. Timeout 300 (The maximum waiting time for the client to be idle. The connection is closed after the maximum waiting time is reached. To disable this function, set it to 0.)

After understanding the core configuration that Redis must know, we create log, data, conf files in the Redis directory

/usr/local/redis/ CD /usr/local/redis/Copy the code

After creation, the following figure is displayed

Conf file and edit the redis.conf file to copy the following custom configuration files

Custom configuration files

# # any IP access to bind 0.0.0.0 daemon daemonize yes 123456 # # password requirepass logfile log file "/ usr/local/redis/log/redis log" /usr/local/redis/data /usr/local/redis/data /usr/local/redis/dataCopy the code

Start the redis specified configuration file

./redis-server .. /conf/redis.confCopy the code

When the configuration file is ready, you can go to the redis. Log file to view the related log, as shown in the picture, there is no problem, perfect!

Then go to the bin directory for Redis connection

# CD bin/ #./redis-cli -a 123456Copy the code

Key naming specification

In the actual project development, in order to facilitate the management of user data, the Key of Redis is named according to the following specifications:

1) Easy to manage + easy to read

2) Do not be too long, the key itself also takes up space

3) Use colons and do not use other special characters (whitespace – quotes – escapes)

Example: business name: table name: ID

Well, that’s all for this article. If it helps you, please pay attention. One last tool for redis6: try.redis. IO /