当前位置:网站首页>Redis installation (Windows) and common usage methods
Redis installation (Windows) and common usage methods
2022-07-18 12:32:00 【Perfectkn】
Catalog
Configure environment variables
String Basic operation of string
mset and mget Batch write and read
lpush/rpush and lrange Insert and get
sadd Insert and smembers Take out
srem Delete the specified value
install
Windows Version download address :Releases · microsoftarchive/redis · GitHub
After downloading the installation package, unzip it , The folder is as follows .

cli It can be understood as a client ,server Understood as server side , The next step is to simply set environment variables .
Configure environment variables
First, put the mouse on “ This computer ” On , Right click the attribute , Find the advanced system Settings , The following operations are shown in the figure .




After clicking New, you can paste the directory you extracted into , For example, I unzip it to E:\Redis , Then keep making sure .
notes :Win10 You can also enter directly into the search box in the lower left corner env Call out the environment variables page .
then , Click the lower left corner to search there and enter “cmd” Call command prompt terminal , There is no search box where to open cmd Will do , Input redis-cli, If the following content appears, the configuration is successful .

Redis Common operations
The article only gives examples of some commonly used operations , More operation reference redis Command manuals :Redis Command Reference — Redis Command Reference
Redis The five data types of are :Srting( character string )、Hash( Hash )、List( list )、Set( aggregate ) and zset( Ordered set ). Install well Redis after , The default is 16 A database , For the first time, it is used by default 0 Signal library .
Common operations
Switch database :select Numbers ; such as select 1, The delegate switches to 1 The database .
Check how many pairs there are in the current library key-val:dbsize;
Delete library :①flushdb Delete all data in the current library ②flushall Delete 16 All data in a library .
String Basic operation of string
Set add to
The format is :SET key value
Be careful : ①set It can be uppercase or lowercase
②key Representative Key , Self defined
③value Representative value

notes :“” Double quotation marks can be omitted , If value What you input is Chinese , So it doesn't show .get Will show you the transcoded Chinese . But when the program is coded, you can turn it into a string and it can be displayed normally .
Get obtain
Format :get key.

del Delete
Format :del key
setex Delete regularly
Format :setex key Number of seconds value

I'll put name Set to 10 Automatically delete... In seconds ,10 Seconds get You can read hello,10 It cannot be read after seconds .
mset and mget Batch write and read
Format :mset key1 value key2 value
mget key1 key2

Hash Basic operation of hash
Redis hash Is a set of key value pairs .
Redis hash It's a string Type of field and value Mapping table ,hash Ideal for storing objects .
give an example : Store one user Information
user name "smith" age 30 job "coder"
explain :
key:user
name "smith" age 30 job "coder" Three pairs field-value
hset and hget
hset and hget You can only add or read one by one .

As long as you read it, it is a string string type , For example, look at that age Read is “30”.
hgetall user You can read all the fields you added .
hmset and hmget
hmset and hmget Can help you add at one time / Read multiple fields .

hlen
Count one hash There are several elements .

List List basic operations
List is a simple list of strings , Sort by insertion order . You can add an element to the head of the list ( On the left ) Or the tail ( On the right ).
List The essence is a chain list ,List Of Elements are ordered , Elemental Values can be repeated .
lpush/rpush and lrange Insert and get
lpush Means to insert from the left ,rpush Means to insert from the right ,lrange Indicates reading from left to right .
lrange Format :lrange key start stop
Examples are as follows :


lrange hinder 0 Indicates that starting from the first element ,-1 That's the last element , Of course -2 It means the penultimate element .
lpop and rpop Delete
lpop: Make the current list the most Left Element deletion of edge .
rpop: Make the current list the most Right Element deletion of edge .


del
Delete a list

llen Find the length
Format :llen key
return key The length of , If key non-existent , Then return to 0

lindex
Returns a list of
keyin , Subscript to beindexThe elements of . from 0 Start .

Because it is inserted from left to inside ,a In the innermost , At this time, the order of the list is c,b,a, So the index is 2 Yes. a.
Set Set basic operations
set yes string Unordered collection of type .
The bottom is Hash Table data structure ,Set It's also Store many string elements , String elements are unordered , and The value of an element cannot be repeated .
sadd Insert and smembers Take out
give an example : Store multiple email messages
key:email
value: mailing address

As can be seen from the above set Set elements are unordered .
![]()
It means that I had [email protected] 了 . Now add another Same value The element of .
sismember Judge
You can determine whether the value is a member , It can be understood as s is member

srem Delete the specified value

边栏推荐
- openEuler 知:ip addr 查不到 ip 的解决方法
- Openeuler knowledge: official Community
- [idea] add VM options to idea
- FreeRTOS个人笔记-初谈CM3内核
- Sorting of two fields in redis
- [object header] view the bytes occupied by the object
- [jailhouse article] bao: a modern lightweight embedded hypervisor (2020)
- 【idea】idea添加vm options
- 秋招问题汇总
- 【微信小程序】基本橫向、纵向滚动Scroll-view(95/100)
猜你喜欢
![[C language] structure, enumeration, union](/img/1d/1ed4a926d52c5e4f08dd50ef4db2fb.jpg)
[C language] structure, enumeration, union

Flink基础记录补充
![[object conversion] vo2dto use](/img/fa/5a0fefcf886fa74d3df0dead565aa5.png)
[object conversion] vo2dto use

c语言基础篇:指针(初阶)
![[jailhouse article] bao: a modern lightweight embedded hypervisor (2020)](/img/d6/ff217b1690a6fc6c935dcf5e24e926.png)
[jailhouse article] bao: a modern lightweight embedded hypervisor (2020)

【idea】idea添加vm options

["plaything determination" scratch children programming] tank turbulence - "implementation of" through wall control "and" bullet rebound "- including complete code

中文版《开放敏捷架构精选示例案例研究》官网正式上线,精彩先睹为快!

逆向学习笔记(一)

Tri des deux champs dans redis
随机推荐
vue+mysql连接数据库实现登录注册
Chinese character style transfer -- unsupervised font style conversion model based on generative confrontation network
Logic of automatic reasoning 02 propositional calculus
Installing MySQL on Linux
从应用到底层:36张图带你进入Redis世界(上)
[wechat applet] slide effect realization
Image denoising using nlmeas
Flink基础记录补充
Kettle [practice 01] under linux environment, Azkaban is used to call kettle's KJB or KTR script regularly to realize automatic data processing (complete process example sharing: cloud resources inclu
What is the function of GIS service platform for pipe network management?
防抖节流详解及示例
C# 使用JObject解析嵌套json
Rust language -- xiaoxiaobai's introductory learning 10
What are the five common data types of redis? What is the corresponding data storage space? Take you to learn from scratch
谷歌 | 图神经网络预训练帮助了分子表征吗
[chicken soup] things are difficult and easy in the world
模拟实现C语言中常用函数
Sorting of two fields in redis
Ftxui basic notes (Hello World)
接口自动化测试:Postman实战教程