当前位置:网站首页>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 -p123
mysql 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
边栏推荐
- 【数据挖掘】任务4:20Newsgroups聚类
- [data mining] task 2: mimic-iii data processing of medical database
- [understanding of opportunity -36]: Guiguzi - flying clamp chapter - prevention against killing and bait
- Introduction to kotlin collaboration
- STM32 - vibration sensor control relay on
- 疫情當頭,作為Leader如何進行團隊的管理?| 社區征文
- Related concepts of GDB in embedded system
- STM32 - introduction of external interrupts exti and NVIC
- Scheme and practice of cold and hot separation of massive data
- Network security - phishing
猜你喜欢
Leetcode skimming questions_ Sum of two numbers II - enter an ordered array
Take you ten days to easily complete the go micro service series (I)
Scheme and practice of cold and hot separation of massive data
Vant 实现简单的登录注册模块以及个人用户中心
【Camera专题】OTP数据如何保存在自定义节点中
Installation and use of serial port packet capturing / cutting tool
Niuniu's ball guessing game (dynamic planning + prefix influence)
STM32 - introduction of external interrupts exti and NVIC
Anna: Beibei, can you draw?
树形结构数据的处理
随机推荐
【Camera专题】Camera dtsi 完全解析
Processing of tree structure data
Summary of interval knowledge
Tâche 6: regroupement DBSCAN
Network security ACL access control list
File class (check)
【数据挖掘】任务3:决策树分类
In the face of difficult SQL requirements, HQL is not afraid
Comment le chef de file gère - t - il l'équipe en cas d'épidémie? Contributions communautaires
¢ growth path and experience sharing of getting an offer
Take you ten days to easily complete the go micro service series (I)
云原生题目整理(待更新)
Custom components, using NPM packages, global data sharing, subcontracting
Take you ten days to easily complete the go micro service series (II)
Certaines fonctionnalités du développement d'applets
网络安全-浅谈安全威胁
[Appendix 6 Application of reflection] Application of reflection: dynamic agent
Introduction to kotlin collaboration
Asian Games countdown! AI target detection helps host the Asian Games!
Analyzing several common string library functions in C language