Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos7 yum installs redis and what are the common commands

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "centos7 yum installs redis and what are common commands". In daily operation, I believe many people have doubts about installing redis in centos7 yum and what common commands are. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "what are centos7 yum installation redis and common commands?" Next, please follow the editor to study!

What is redis?

Redis is a memory-based data structure storage, persistent log-type, Key-Value database. When sites using relational databases reach a certain amount of concurrency, there will often be bottlenecks on disk IO. At this time, cooperating with redis has certain advantages, because it has the following features:

Run based on memory with high concurrency of read and write

It supports distribution and can be expanded infinitely in theory.

Rich data types

Persistence, which can be written to disk on a regular basis

Application scenario

Cache "hot spot" data (high frequency read, low frequency write)

Counter, current limiter

Message queuing system (publish subscription, ranking)

Distributed locks, shared session, queues

Data type:

The data types provided by Redis are mainly divided into five own types and one custom type, which include:

String (String) type, hash (Hash) type, list (List) type, Set type, and Sorted Set (Sorted Set) collection type.

String type:

It can store strings, pictures, videos and other types, with a maximum length of 512m. Operation commands, such as:

GET/MGET

SET/SETEX/MSET/MSETNX

INCR/DECR

GETSET

DEL

Hash type:

This type is a map consisting of a field and an associated value. Where field and value are both string types. The operation commands are as follows:

HGET/HMGET/HGETALL

HSET/HMSET/HSETNX

HEXISTS/HLEN

HKEYS/HDEL

HVALS

List type:

This type is a collection of string elements sorted in insertion order, based on a double-linked list implementation. The operation commands are as follows:

LPUSH/LPUSHX/LPOP/RPUSH/RPUSHX/RPOP/LINSERT/LSET

LINDEX/LRANGE

LLEN/LTRIM

Collection type:

The Set type is an unordered collection, and the biggest difference between it and the List type is that the elements in the collection are unordered and unique.

The bottom layer of the Set type is implemented through a hash table, and its operation command is:

SADD/SPOP/SMOVE/SCARD

SINTER/SDIFF/SDIFFSTORE/SUNION

Set type is mainly used in some scenarios, such as social scenarios, through intersection, union and subtraction operations, through the Set type can easily find common friends, common concerns and common preferences and other social relationships.

Sequential collection type:

ZSet is an ordered collection type, and each element is associated with a fractional weight of type double, which is used to sort the members of the collection from small to large.

Like the Set type, the underlying layer is implemented through a hash table. ZSet command:

ZADD/ZPOP/ZMOVE/ZCARD/ZCOUNT

ZINTER/ZDIFF/ZDIFFSTORE/ZUNION

Quickly install yum install redis

Direct yum installation redis is not the latest version, you can install the latest Redis through Remi.

Yum install-y epel-release

Yum install-y http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Remi's RPM repository maintains the latest and additional software packages, so it's best to install EPEL first, because the Remi repository depends on it.

Install the latest version of Redis using the following command:

Yum-enablerepo=remi install redis

After installation, the redis service can be started and booted to start itself.

Systemctl start redis

Systemctl enable redis

View the redis version:

Redis-cli-version

Redis default 127.0.0.1 access, turn on remote login remember to set the password!

Common command

Commands are often used in testing

Redis client connection: local connection: redis-cli remote connection: redis-cli-h host-p port-a passwordPING to see if the service is running SELECT index switch to the specified database select 0 Select the first library keys * get all keyflush db cleanup specified libraries flushall clear all

Several types of common commands

String set key value get keyhash hset myhash name cxx hget myhash namelist lpush mylist a b c left insert rpush mylist x y z right insert lrange mylist 0-1 data collection lpop mylist pop-up element rpop mylist pop-up element llen mylist length lrem mylist count value delete set sadd myset redis smembers myset data set srem myset set1 delete zset zadd zset 1 one zadd zset 2 two zadd zset 3 three to this The study on "centos7 yum installs redis and what are the common commands" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report