【11】Redis study notes (Microsoft windows version)【Redis】

Note: The official redis version does not support the windows version and only supports linux. 

This note is based on the Windows version developed by Microsoft. 

I. Introduction

Introduction to Redis:

Redis (Remote Dictionary Server) is an open source in-memory data structure storage system. It is also called a data structure server. Redis stores data in the form of key-value pairs and supports a variety of data structures, such as strings, hash tables, lists, sets, ordered sets, etc. It was developed by Salvatore Sanfilippo and first released in 2009.

Key-value database:

Key restrictions:

  1. Length limit: The maximum length of a key is 512MB.
  2. Data type: The key must be a string type. Other data types (such as hash tables, lists, etc.) cannot be used as keys.
  3. Naming rules: Keys can contain arbitrary binary data, but it is generally recommended to use short, easy-to-understand strings as key names.

Limitations on value:

  1. Length limit: The maximum length of a value is also 512MB.
  2. Data type: Redis supports multiple data types, so values ​​can be strings, hash tables, lists, sets, ordered sets and other data types.
  3. Data format: String values ​​can contain arbitrary binary data, while values ​​of other data types must be stored according to the corresponding data structure format.

 Redis learning graphic materials:

Graphical introduction to Redis | Xiaolin coding (xiaolincoding.com)

2. Learn Redis

1. Getting started with Redis

(1) Understand NoSQL

NoSQL (Not Only SQL) is a general term for a type of non-relational database management system. It is different from traditional relational databases (such as MySQL, Oracle, etc.), mainly in the data model and data storage method. The design goal of NoSQL databases is to solve the shortcomings of relational databases in certain scenarios, especially the challenges in large-scale distributed systems and massive data processing.

Some main features and introduction of NoSQL databases:

  1. Non-relational data model: NoSQL databases usually adopt non-relational data models and do not need to follow traditional table and relational constraints. This allows data to be stored in a more flexible way and is suitable for processing semi-structured, unstructured or complex data.

  2. Horizontal scalability: NoSQL databases usually have good horizontal scalability and can distribute data on multiple servers to achieve better load balancing and horizontal expansion. They are suitable for processing large-scale data and high concurrent requests.

  3. High performance: Since NoSQL databases are designed with more emphasis on performance and scalability, they can provide higher read and write performance in certain scenarios, especially for a large number of concurrent read operations.

  4. Flexible data model: NoSQL database supports a variety of data structures and data models, such as key-value storage (Key-Value), document database (Document), column-family storage (Column-Family) and graph database (Graph). These different data models can better adapt to different types of data and application needs.

  5. Consistency model: In some NoSQL databases, in order to achieve better performance and availability, the ACID transaction characteristics in traditional databases may be relaxed and a model based on eventual consistency (Eventual Consistency) is adopted.

  6. Distributed architecture: Many NoSQL databases are designed to run in a distributed environment, so they usually have the ability to replicate and synchronize data on multiple nodes to ensure data reliability and high availability.

Storage format

1. Key-value type: Redis

2. Document type: MongoDB

3. Picture:

(2) Understanding Redis

feature:

1. Key-value type, value supports a variety of different structures and has rich functions.

2. Single thread, each command is atomic

3. Low latency and fast speed ( based on memory , IO multi-channel taking, good coding)

4. Support data persistence

5. Support master-slave cluster and shard cluster

6. Support multi-language clients

(3) Install Redis

Officially, the windows version is not supported, only linux is supported.

There is no need to use Linux here. Choose the Windows version developed by Microsoft. Note that it is 64-bit.

Releases · microsoftarchive/redis (github.com)

Download the installation package and unzip it

Enter the unzipped directory and enter cmd

Enter the command to start the service

redis-server.exe redis.windows.conf

 

This method is the foreground startup method (window running, service running, window closed, service closed)

At this time, to connect to the redis service, you need to start another cmd window and enter the command.

redis-cli

 

How do we keep this service running? We need to add this process to the windows service.

redis-server --service-install redis.windows.conf

 Enter service

 We can see that the addition was successful

 Right-click to start. At this time, you can close the redis cmd service running window.

 

(4) Redis configuration

Find the redis.windows.conf configuration file and open it for editing

 

 

1、登录监听的地址
bind (127.0.0.1是只允许本地访问) (0.0.0.0为任意都允许访问)

2、守护进程
daemonize yes (设置为yes后即可后台运行)

3、密码
requirepass "你的密码" (设置后访问redis必须输入密码,注意windows服务也要配置密码)

4、监听端口
port 6379

5、工作目录
dir . (默认为当前目录)

6、设置redis最大能使用内存
maxmemory 512mb

7、数据库的数量
databases 1 (redis数据库是提前创建好的,只能控制数量)

8、日志文件,默认为空,不记录日志,key制定日志文件名
logfile "redis.log"

 On Windows, daemonize and pidfile are not supported. # However, you can run redis as a Windows service and specify a log file. #The log file will contain the pid. 

I only changed two items here for learning and testing

1. Set up log files

2. Change bind to 0.0.0.0 

 

 Pay attention to save after making changes

pending upgrade

August 15, 2023 18:21:37 
 

Guess you like

Origin blog.csdn.net/qq_53478650/article/details/132115210