当前位置:网站首页>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
边栏推荐
- Caused by: com. fasterxml. jackson. databind. exc.MismatchedInputException: Cannot construct instance o
- Reprint some Qt development experience written by great Xia 6.5
- 网络安全-扫描与密码爆破2
- Niuniu's ball guessing game (dynamic planning + prefix influence)
- 【数据挖掘】任务1:距离计算
- 查询商品案例-页面渲染数据
- The technology boss is ready, and the topic of position C is up to you
- In 2022, 95% of the three most common misunderstandings in software testing were recruited. Are you that 5%?
- Redis:Redis的简单使用
- 网络安全-漏洞与木马
猜你喜欢
Why can't the start method be called repeatedly? But the run method can?
[Appendix 6 Application of reflection] Application of reflection: dynamic agent
One of the C language practical projects is greedy snake
深度(穿透)选择器 ::v-deep/deep/及 > > >
Vant 实现简单的登录注册模块以及个人用户中心
[error record] navigator operation requested with a context that does not include a naviga
Smart management of Green Cities: Digital twin underground integrated pipe gallery platform
Everything file search tool
[shutter] animation animation (animatedbuilder animation use process | create animation controller | create animation | create components for animation | associate animation with components | animatio
Button button adaptive size of wechat applet
随机推荐
全链路数字化转型下,零售企业如何打开第二增长曲线
[fluent] hero animation (hero animation use process | create hero animation core components | create source page | create destination page | page Jump)
[camera topic] turn a drive to light up the camera
STM32 - GPIO input / output mode
Cloud native topic sorting (to be updated)
【Camera专题】Camera dtsi 完全解析
小程序开发黑马购物商城中遇到的问题
Modify table structure
Network security - Information Collection
Internal connection query and external connection
Network security - phishing
[shutter] animation animation (animatedbuilder animation use process | create animation controller | create animation | create components for animation | associate animation with components | animatio
网络安全-浅谈安全威胁
函数的定义和调用、this、严格模式、高阶函数、闭包、递归
[camera topic] how to save OTP data in user-defined nodes
Network security NAT network address translation
Summary of interval knowledge
Introduction to flask tutorial
网络安全-动态路由协议RIP
[understanding of opportunity -36]: Guiguzi - flying clamp chapter - prevention against killing and bait