当前位置:网站首页>[redis] install redis in Ubuntu and the basic usage and configuration of redis
[redis] install redis in Ubuntu and the basic usage and configuration of redis
2022-06-22 01:03:00 【sinat_ twenty-one million seven hundred and ninety-one thousand】
Link to the original text :https://www.cnblogs.com/donghaonan/p/10403781.html
For the convenience of learning to view , Temporary record , Invasion and deletion
1. install redis Use command sudo apt-get install redis-server
whereis redis see redis Installation position of
ps -aux | grep redis see redis The process of the service runs
netstat -nlt | grep 6379 according to redis View the running port number redis Server status , Port number preceded by redis Service Monitor IP( By default, it's local IP 127.0.0.1)
2. start-up redis
Local boot redis-cli
Remote connection ( Need to install locally redis client ) redis-cli -h host( long-range ip) -p port( Port number ) -a password( password )
3.redis Configuration of
config get * see redis All configuration parameters of
config get (name) see redis A configuration parameter
config set (name) (value) modify redis Some of the configurations ( Some configuration modifications do not support this operation , For example, modify bind)
Operations that do not support client modification need to be modified redis Configuration file for sudo vi /etc/redis/redis.conf
for example : Modify the configuration file redis.conf Configure remote access
(1) Look in the configuration file for bind 127.0.0.1 Annotate Change it to #bind 127.0.0.1
(2) Restart redis that will do
4.redis Use
Basic use :
del key Used to delete existing key
keys pattern View all that match the pattern key
for example keys * View all key
exists key see key Whether there is
type key see key Storage type of
rename key newkey modify key The name of
redis It mainly includes 5 Data type string in (String)、 Hash (Hash)、 list (list)、 aggregate (Set)、 Ordered set (Sorted set)
(1) character string (String) Type main operation
set key value For a given key Set the value
get key Get specified key Value
getrange key start end Get specified key Value substring start <= String <= end
mget key1 key2 ... Get all the given key value
strlen key return key The length of the stored string value
append key value If key Already exists and is a string ,append Specifies the value Append to the key It was worth the end , Otherwise, add a new key The value is value
(2) Hash (Hash) The main operation of type
hmset key field1 value1 field2 value2 ... Will be multiple field-value( Domain - value ) Set to hash table key in
hmget key field1 field2 ... Get the value of all the given fields
hdel key field1 field2 ... Delete one or more fields
hexists key field Look at the hash table key in , Specifies whether the field exists
hget key field Get the information stored in the hash table key The value of the specified field in
hset key field value take key The field value in is set to value
hgetall key Get hash table key All fields and values in
hkeys key Get all hash tables key Middle field
hvals key Get all values in hash table
hlen key Get hash table key The number of fields in
(3) List the type (list) The main operation of
lpush key value1 value2 ... Insert one or more values into the list header
rpush key value1 value2 ... Insert one or more values at the end of the list
lpop key Remove and get the first element of the list
rpop key Remove and get the last element of the list
lindex key index Get the elements in the list by index
linsert key before | after pivot value In the list element pivot Insert elements before or after value
llen key Get list length
lrange key start end Get the elements in the specified range of the list
lrem key count value Remove list elements
remarks :
count > 0 : Search from header to footer , Remove and VALUE Equal elements , The number of COUNT .
count < 0 : Search from the end of the table to the header , Remove and VALUE Equal elements , The number of COUNT The absolute value of .
count = 0 : Remove all and from the table VALUE Equal value .
lset key index value Set the value of the list element through the index
ltrim key start end Let the list keep the interval start end Elements in scope , Delete other elements
(4) Collection types (set) The main operation of
sadd key member1 member2 ... Add one or more members to the collection
scard key Get the number of members of the collection
sdiff key1 key2 Get the difference set of the set return key1 There is , key2 Not found in , It is related to the sequence
sinter key1 key2 obtain key1 and key2 Intersection
sismember key member Judge member Whether it is key Member of the
smembers key return key All the members of the
spop key Remove and return key A random element in
srandmember key [count] return key One or more random numbers in count Value setting returns a random number
srem key member1 member2 ... Remove one or more members of the collection
sscan key cursor match [pattern] [COUNT count] Iterate over the elements in the collection
remarks :
cursor Where the scan starts 0 1 etc.
match pattern Regular matching is used for filtering
cout Number of scans
(5) Ordered set (sorted set) The main operation of type
zadd key score1 member1 score2 member2 ... Add one or more members to an ordered collection , Or update scores of existing members
zcard key Get the number of members of the ordered set
zcount key min max Calculates the number of members of a specified interval fraction in an ordered set
zrange key start end Return the members in the specified interval of the ordered set through the index interval
zrank key member Returns the index of a specified member in an ordered collection
zrem key member1 member2 ... Remove one or more members from an ordered set
zrevrange key start end Returns the members of a specified interval in an ordered set , Through the index , Score from high to the end
zrevrank key member Returns the rank of a specified member in an ordered set , Ordered sets are arranged in order of the fraction
zscore key member Returns the member score value in an ordered set
zscan key cursor [match pattern] [count] Iterate over elements in an ordered set ( Include element members and element scores )
边栏推荐
- 合理选择液压滑环密封间隙的重要性
- 均线策略专测
- VScode 中查看本地ip地址
- Pytorch learning 10: statistical operations
- Div set scrolling and monitor scrolling distance
- 调试中的虚变量和格式化字符
- Pytorch learning 02: handwritten digit recognition
- ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
- [2023 approved in advance] Qingdao Dingxin Technology
- 合理选择液压滑环密封间隙的重要性
猜你喜欢

前加后加探索和函数调用探索

0x00007ffff3d3ecd0 in _IO_vfprintf_internal (s=0x7ffff40b5620 <_IO_2_1_stdout_>

pytorch学习01:梯度下降实现简单线性回归

合理选择液压滑环密封间隙的重要性

RISCV 的 cache

【DailyFresh】课程记录3--商品搜索相关

0x00007ffff3d3ecd0 in Io Vfprintf Interne (S = 0x7ffff40b5620 < io 2 1 stdout >

pytorch学习08:拼接与拆分

Meetup03 review: introduction to the new version of linkis and the application practice of DSS

Pytorch learning 07:broadcast broadcast - automatic extension
随机推荐
Status code summary
均线策略专测
Pytorch learning 01: gradient descent for simple linear regression
Acwing game 56
【Redis】ubuntu中安装redis以及redis的基本使用和配置
Are Huishang futures accounts reliable? How can a novice safely open an account?
cygwin下面用mysql client连接服务器的问题
0x00007ffff3d3ecd0 in _IO_vfprintf_internal (s=0x7ffff40b5620 <_IO_2_1_stdout_>
sed 技巧
yolov3 3D 语义点云paper阅读
Two popular architectures for web application system development
Chapter VIII exercises (45A) [microcomputer principles] [exercises]
位运算位与
Pytorch learning 04: creation of tensor
div设置滚动和监听滚动距离
0x00007ffff3d3ecd0 in _ IO_ vfprintf_ internal (s=0x7ffff40b5620 <_IO_2_1_stdout_>
Enterprises can improve database security in four ways
手写数据库连接池
Emperor Taizong of Tang Dynasty played the "heartbeat mechanism" of microservices to the extreme!
导电滑环是如何工作的