How do I add delete change and check Redis using the console

  • 2020-06-12 11:09:20
  • OfStack

preface

This article mainly introduces the console implementation of Redis to add, delete, change and check the command related content, share for your reference and learning, the following words do not say much, let's have a look at the detailed introduction

Methods the following

There are many ways to open the console in windows system. I like to open the console by using the shortcut "win+R" to open "Run" and typing "cmd".

Type commands in the console


redis-cli

This will open an Redis prompt

[

127.0.0.1:6379 >

]

Indicates that the ip: 127.0.0.1, port: 6379 Redis service has been linked

We can use the "PING" command to check if Redis is working as follows:


127.0.0.1:6379> PING
PONG
127.0.0.1:6379>

Indicates that Redis is working properly.

If you install it according to my previous article and set the password, it will appear as follows:

[

127.0.0.1:6379 > ping
(error) NOAUTH Authentication required.

]

The login command is "AUTH" and my password is "admin", as shown below:

[

127.0.0.1:6379 > auth admin
OK

]

After successful login, we can enter the theme.

Redis supports a variety of data types, here I briefly introduce string additions, deletions, changes, and search first, hoping to be a bit of a tidbit

The Redis string is a sequence of bytes. In Redis strings are binary safe, which means that they have a known length and are not terminated by any special character, so they can store anything up to 512 megabytes in length.

Add and modify using the "SET" command

For example, add one key to "key001" and the value is "val001"


127.0.0.1:6379> set key001 val001
OK

Read using the "GET" command


127.0.0.1:6379> get key001
"val001"

Delete using the del command


127.0.0.1:6379> del key001
(integer) 1
127.0.0.1:6379> get key001
(nil)
127.0.0.1:6379>

In Redis, "(nil)" means that the key does not exist.

conclusion


Related articles: