当前位置:网站首页>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
边栏推荐
- 【数据挖掘】任务3:决策树分类
- Network security - vulnerabilities and Trojans
- Everything file search tool
- Processing of tree structure data
- [technology development-23]: application of DSP in future converged networks
- PS去除水印详解
- 浏览器是如何对页面进行渲染的呢?
- [data mining] task 1: distance calculation
- 【Camera专题】OTP数据如何保存在自定义节点中
- Network security - the simplest virus
猜你喜欢
[data mining] task 5: k-means/dbscan clustering: double square
mysql
Custom components, using NPM packages, global data sharing, subcontracting
[data mining] task 4:20newsgroups clustering
可视化yolov5格式数据集(labelme json文件)
Anna: Beibei, can you draw?
Vant implements a simple login registration module and a personal user center
[shutter] animation animation (animatedbuilder animation use process | create animation controller | create animation | create components for animation | associate animation with components | animatio
High resolution network (Part 1): Principle Analysis
What are the differences between software testers with a monthly salary of 7K and 25K? Leaders look up to you when they master it
随机推荐
Introduction to flask tutorial
云原生题目整理(待更新)
Vant implements a simple login registration module and a personal user center
word插入公式/endnote
Leetcode skimming questions_ Sum of two numbers II - enter an ordered array
[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
Modify table structure
Answers to ten questions about automated testing software testers must see
【数据挖掘】任务4:20Newsgroups聚类
File class (check)
网络安全-中间人攻击
网络安全-破解系统密码
Problems encountered in small program development of dark horse shopping mall
Asian Games countdown! AI target detection helps host the Asian Games!
[camera topic] how to save OTP data in user-defined nodes
Performance test | script template sorting, tool sorting and result analysis
High resolution network (Part 1): Principle Analysis
The technology boss is ready, and the topic of position C is up to you
String splicing function of MySQL
[North Asia data recovery] data recovery case of raid crash caused by hard disk disconnection during data synchronization of hot spare disk of RAID5 disk array