当前位置:网站首页>Redis: simple use of redis
Redis: simple use of redis
2022-07-03 01:54:00 【dengfengling999】
Catalog :
(1)Redis The details of using
start-up 、 close 、 Start client
(2)Redis Basic knowledge of 1
Test performance 、 View the status transition 、 Server statistics
(3)Redis Basic knowledge 2
Database instance
(4)Redis Basic knowledge 3
see key、 Empty library
(1)Redis The details of using

Starting mode :
(1) The front desk starts :redis-server: After starting , It will occupy the whole console and command line terminal , You can't do anything else , Once the command line is closed , Its service is shut down , This method is rarely used in the actual development process
(2) Background start :redis-server & The console will not occupy the entire command line terminal , That is, the command line is turned off , Start the background service as it should be
(3) When starting the service , Specify profile :redis-server redis-conf & If the configuration file is modified , Required at startup , Specify profile
Close the way :
- adopt kill command , This is not recommended , Easy to lose data
ps -ef | grep redis see pid
kill -9 pid
2. adopt redis-cli Order to shut down
redis-cli shutdown
start-up :redis-server &

To view the :ps -ef|grep redis: Found to have 6379 This redis

close Redis:redis-cli shutdown

To view the :ps -ef|grep redis: No port number 6379 Of redis

Redis After the server is installed , Can't be used directly , If you want to use , You must connect him through the client , Input some commands through the client and send them to him through the network , The server executes these commands , To complete the addition, deletion, modification and query of these data , And return the results of the addition, deletion, modification and query to the client
for example :MySql:
1、mysql Command connection database format :
mysql -h The host address -P Port number -u user name -p User password 2、MySQL Connect to local database , The user is called “root”, password “123”
mysql -h localhost -u root -p123mysql It's more troublesome based on the command line , We find it inconvenient , So there are visualization tools Navica Clients clients developed by third parties , This client can also connect Mysql Server side , To the backstage Mysql Send some commands , The server can return the result to the client , This visual interface brings us great convenience .
Redis client
Redis The client is a program , Connect to Redis The server , So as to realize the following Redis Server interaction .
Redis Client sends command , Show at the same time Redis Server processing results .
redis-cli(Redis Command Line Interface) yes Redis Built in command line based Redis client , It is used to interact with the server , We can use this client to perform redis All kinds of orders .
start-up Redis client :
1) Direct connection redis ( Default ip127.0.0.1, port 6379):redis-cli
Execute... In any directory redis-cli
This command is to connect the local machine 127.0.0.1 , port 6379 Of redis

You can specify the port number :
2) Appoint IP And port connection redis:redis-cli –h 127.0.0.1 -p 6379
-h redis host IP( You can specify any redis The server )
-p Port number ( Different ports mean different redis application )
Execute... In any directory redis-cli -h 127.0.0.1 -p 6379

- sign out Redis client :exit perhaps quit Instructions .

(2)Redis Basic knowledge of 1

- test Redis performance


2.Redis Communication command , Check the status
redis >ping return PONG
explain : Input ping,redis Come back to us PONG, Express redis The service is running normally

3. see redis Server statistics :info
grammar :info [section]
effect : In a format that is easy to explain and easy to read , Return to about Redis All kinds of information and statistics of the server .section Used to return the statistics of the specified part . section Value :server , clients ,memory wait . No addition section Return all statistics
Return value : Appoint section Statistics or all information about
example 1: Statistics server Information about

example 2: Count all the information

(3)Redis Basic knowledge 2

MySQL Database instance in , It can be created by developers , You can create , You can name yourself , You can maintain
Redis Database instance of , Only by Redis Create and maintain by yourself , If programmers want to use , You can't create it yourself, just use the creation number
- redis By default 16 Databases
Redis By default 16 Databases , from 0 To 15. Modify the number of databases , stay redis.conf In file databases 16, Theoretically, you can configure an unlimited number of .

Redis The library is similar to a database instance in a relational database , But there are some differences , such as redis Each library in cannot be named by user , It can only be expressed by serial number ,redis Each library in is not completely independent , It is best to use one for each application redis example , Not recommended redis Save the data of multiple applications in the instance .Redis The storage space occupied by the instance itself is actually very small , So there is no waste of storage space .
for example : use set Command to save a data , By default, the client is connected to 0 No. instance

2. Switch library commands :select db
By default, use section 0 individual , If you want to use another database , The order is select index

(4)Redis Basic knowledge of 3
1. View the current database key Number of :dbsize
grammar :dbsize
effect : Returns the... Of the current database key The number of .
Return value : Numbers ,key The number of

Just put a piece of data , Why 2 Well ?
:0 The number is quite special , There are several pieces of data in it by default

2. View what is in the current database key:keys *


3. Empty the current library :flushdb

4. Clear all databases :flushall Empty all database instances

It also shows redis The libraries in are not completely irrelevant .

4.config get * get redis All configuration values for
grammar :config get parameter
effect : Get running Redis Configuration parameters of the server , Get all the configurations you can use *. The parameter information comes from redis.conf The content of the document .
example 1: Get the number of databases config get databases

example 2: Get the port number config get port

边栏推荐
- 7-25 read numbers (loop switch)
- In 2022, 95% of the three most common misunderstandings in software testing were recruited. Are you that 5%?
- 网络安全-密码破解
- Vant 实现简单的登录注册模块以及个人用户中心
- Network security - man in the middle attack
- [Yu Yue education] Jiujiang University material analysis and testing technology reference
- Everything file search tool
- word插入公式/endnote
- 浏览器是如何对页面进行渲染的呢?
- JUC thread scheduling
猜你喜欢
![[data mining] task 2: mimic-iii data processing of medical database](/img/ad/4e7b253d60b29351e3ef252ee5230f.png)
[data mining] task 2: mimic-iii data processing of medical database

Scheme and practice of cold and hot separation of massive data

可视化yolov5格式数据集(labelme json文件)
![[error record] navigator operation requested with a context that does not include a naviga](/img/53/e28718970a2f7226ed53afa27f6725.jpg)
[error record] navigator operation requested with a context that does not include a naviga

A simple tool for analyzing fgui dependencies

The testing process that software testers should know

Asian Games countdown! AI target detection helps host the Asian Games!

CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr

In 2022, 95% of the three most common misunderstandings in software testing were recruited. Are you that 5%?
![[shutter] animation animation (basic process of shutter animation | create animation controller | create animation | set value listener | set state listener | use animation values in layout | animatio](/img/70/54eb9359ac91aa43383b240eb036b7.gif)
[shutter] animation animation (basic process of shutter animation | create animation controller | create animation | set value listener | set state listener | use animation values in layout | animatio
随机推荐
Related concepts of GDB in embedded system
网络安全-病毒
网络安全-破解系统密码
[data mining] task 1: distance calculation
His experience in choosing a startup company or a big Internet company may give you some inspiration
Analyzing several common string library functions in C language
Why can't the start method be called repeatedly? But the run method can?
Openresty cache
[understanding of opportunity -36]: Guiguzi - flying clamp chapter - prevention against killing and bait
Anna: Beibei, can you draw?
PS remove watermark details
Everything file search tool
The technology boss is ready, and the topic of position C is up to you
Introduction to flask tutorial
Network security - talking about security threats
网络安全-openvas
Take you ten days to easily complete the go micro service series (I)
Hard core observation 547 large neural network may be beginning to become aware?
网络安全-钓鱼
word插入公式/endnote