Chart tool
highcharts and echarts and antv
- https://www.highcharts.com.cn/
- https://www.echartsjs.com/zh/index.html
- http://antv.alipay.com/zh-cn/index.html
画图工具
推荐使用 highcharts ,highcharts加载的文件相对来说少一些
highcharts 和 echarts 专注于 pc 端
antv 移动端
repeat
installation
1: Official site: redis.io download the latest version or the latest stable version
2: Unzip the source code and enter the directory
3: no configure
4: Direct make
5: Optional step: make test to test the compilation
(may occur: need tcl> 8.4, yum install tcl)
6: Install to the specified directory, such as / usr / local / redis
make PREFIX=/usr/local/redis install
注: PREFIX要大写
7: After make install, get the following files
- redis-benchmark performance testing tool
- redis-check-aof log file inspection workers (such as log damage caused by power failure, can be detected and repaired)
- redis-check-dump snapshot file detection tool, effect class
- redis-cli client
- redis-server server
8: Copy configuration file
Cp /path/redis.conf /usr/local/redis
9: Startup and connection
-
start up
path/to/redis/bin/redis-server ./path/to/conf-file 例:[root@localhost redis]# ./bin/redis-server ./redis.conf
-
connection
#/path/to/redis/bin/redis-cli [-h localhost -p 6379 ]
10: Let redis run as a background process
编辑conf配置文件,修改如下内容;
daemonize yes
Problems encountered easily: wrong time.
Reason: The source code is officially configured, but when the official configure, the generated file has timestamp information, so if the time of your virtual machine is wrong, for example, 2022, you may get an error
Solution: date -s 'yyyy-mm-dd hh: mm: ss' rewrite time
and then clock -w write cmos
Common data types of redis
String
List
set
Orderly combination
Hash
Operation instruction
1. All operations on key
-
del key1 key2 ... keyn
Function: Delete one or more keys.
Return value: Ignore the non-existent key, and return the number of keys actually deleted. -
rename key newkey
Function: Attach a new key name to the key
Note: If the value of newkey already exists, the original value of newkey is overwritten -
renamenx key newkey
Function: rename the key to newkey and
return: return 1 if modification occurs, return 0 if no modification occurs -
move key db
redis 127.0.0.1:6379[1]> select 2
OK
redis 127.0.0.1:6379[2]> keys*
(empty list or set)
redis 127.0.0.1:6379[2]> select 0
OK
redis 127.0.0.1:6379> keys*- “name”
- “cc”
- “a”
- “b”
redis 127.0.0.1:6379> move cc 2
(integer) 1
redis 127.0.0.1:6379> select 2
OK
redis 127.0.0.1:6379[2]> keys * - "Cc"
redis 127.0.0.1:6379 [2]> get cc
"3"
(Note: A redis process can open more than one database, default is to open 16 databases, numbered from 0 to 15, if you want to open more databases, (Can be modified from the configuration file)
-
keys pattern
The pattern can be selected as follows::
Wildcard any number of characters
?: Wildcard single character
[]: One character in
wildcard redis 127.0.0.1:6379> flushdb
OK
redis 127.0.0.1:6379> keys
(empty list or set)
redis 127.0.0.1:6379> mset one 1 two 2 three 3 four 4
OK
redis 127.0.0.1:6379> keys o *- “one”
redis 127.0.0.1:6379> key* o
(error) ERR unknown command ‘key’
redis 127.0.0.1:6379> keys *o - “two”
redis 127.0.0.1:6379> keys ??? - “one”
- “two”
redis 127.0.0.1:6379> keys on? - “one”
redis 127.0.0.1:6379> set ons yes
OK
redis 127.0.0.1:6379> keys on[eaw]
1)”one”
- “one”
-
randomkey returns a random key
-
exists key to determine whether the key exists returns 1/0
-
type key returns the type of the value stored in the key with string link set order set hash
-
ttl key query key life cycle
-
expire key Integer value sets the life cycle of the key
-
pexpire key milliseconds, set life cycle
-
pttl key, return life cycle in milliseconds
-
persist key Set the specified key to be permanently valid
Note: For non-existent keys or expired keys / non-expired keys, return -1 in
Redis2.8, for non-existent keys, return -2
2. String operations
-
set key value [ex seconds] / [px milliseconds]
set a 1 ex 10 , 10秒有效 Set a 1 px 9000 , 9秒有效 注: 如果ex,px同时写,以后面的有效期为准 如 set a 1 ex 100 px 9000, 实际有效期是9000毫秒
-
mset multi set
一次性设置多个键值 mset key1 v1 key2 v2 ....
-
get key
获取key的值
-
mget key1 key2 ..keyn
获取多个key的值
-
getset key newvalue
获取并返回旧值,设置新值 redis 127.0.0.1:6379> set cnt 0 OK redis 127.0.0.1:6379> getset cnt 1 "0" redis 127.0.0.1:6379> getset cnt 2 "1"
-
incr key
作用: 指定的key的值加1,并返回加1后的值
-
incrby key number
redis 127.0.0.1:6379> incrby age 90 (integer) 92
-
incrbyfloat key floatnumber
redis 127.0.0.1:6379> incrbyfloat age 3.5 "95.5"
-
decr key
redis 127.0.0.1:6379> set age 20 OK redis 127.0.0.1:6379> decr age (integer) 19
-
decrby key number
redis 127.0.0.1:6379> decrby age 3 (integer) 16
Application scenario
When logging in, you can control the frequency control
3. Linked list operation
-
lpush key value
作用: 把值插入到链表头部
-
rpop key
作用: 返回并删除链表尾元素
-
rpush, lpop: don't explain
-
lrange key start stop
作用: 返回链表中[start ,stop]中的元素 规律: 左数从0开始,右数从-1开始
-
ltrim key start stop
作用: 剪切key对应的链接,切[start,stop]一段,并把该段重新赋给key
-
lindex key index
作用: 返回index索引上的值, 如 lindex key 2
-
full key
作用:计算链接表的元素个数 redis 127.0.0.1:6379> llen task (integer) 3 redis 127.0.0.1:6379>
-
linsert key after|before search value
作用: 在key链表中寻找’search’,并在search值之前|之后,.插入value 注: 一旦找到一个search后,命令就结束了,因此不会插入多个value
Scenario: Long polling Ajax, can be used during online chat
4. Collection set operation
-
sadd setname value1 value2
作用: 往集合setname中增加元素
-
srem value1 value2
作用: 删除集合中集为 value1 value2的元素 返回值: 忽略不存在的元素后,真正删除掉的元素的个数
-
spop key
作用: 返回并删除集合中key中1个随机元素
-
srandmember key
作用: 返回集合key中,随机的1个元素.
-
sismember key value
作用: 判断value是否在key集合中 是返回1,否返回0
-
smembers key
作用: 返回集中中所有的元素
-
scard key
作用: 返回集合中元素的个数
-
smove source dest value
作用:把source中的value删除,并添加到dest集合中
-
sinter s1 s2 s3
作用: 求出s1 s2 s3 三个集合中的交集,并返回 redis 127.0.0.1:6379> sadd s1 0 2 4 6 (integer) 4 redis 127.0.0.1:6379> sadd s2 1 2 3 4 (integer) 4 redis 127.0.0.1:6379> sadd s3 4 8 9 12 (integer) 4 redis 127.0.0.1:6379> sinter s1 s2 s3 1) "4" redis 127.0.0.1:6379> sinter s3 s1 s2 1)"4"
-
sinterstore dest s1 s2 s3
作用: 求出s1 s2 s3 三个集合中的交集,并赋给dest
-
suion s1 s2 s3.. sn
作用: 求出s1 s2 s3.. sn的并集,并返回
-
sdiff s1 s2 s3
作用: 求出s1与s2 s3的差集 即s1-s2-s3
5. Ordered set order set operation
-
zadd s1 score1 value1 score2 value2 ..
redis 127.0.0.1:6379> zadd stu 18 lily 19 hmm 20 lilei 21 lilei (integer) 3
-
zrem s1 value1 value2 ..
作用: 删除集合中的元素
-
zremrangebyscore sname min max
作用: 按照socre来删除元素,删除score在[min,max]之间的 redis 127.0.0.1:6379> zremrangebyscore stu 4 10 (integer) 2 redis 127.0.0.1:6379> zrange stu 0 -1 1) "f"
-
zremrangebyrank sname start end
作用: 按排名删除元素,删除名次在[start,end]之间的 redis 127.0.0.1:6379> zremrangebyrank stu 0 1 (integer) 2 redis 127.0.0.1:6379> zrange stu 0 -1 1) "c" 2) "e" 3) "f" 4) "g"
-
zrank key member
查询member的排名(升序 0名开始)
-
zrevrank key memeber
查询 member的排名(降序 0名开始)
-
ZRANGE key start stop [WITHSCORES]
把集合排序后,返回名次[start,stop]的元素 默认是升续排列 Withscores 是把score也打印出来
-
zrevrange key start stop
作用:把集合降序排列,取名字[start,stop]之间的元素
-
zrangebyscore key min max [withscores] limit offset N
作用: 集合(升续)排序后,取score在[min,max]内的元素, 并跳过 offset个, 取出N个 redis 127.0.0.1:6379> zadd stu 1 a 3 b 4 c 9 e 12 f 15 g (integer) 6 redis 127.0.0.1:6379> zrangebyscore stu 3 12 limit 1 2 withscores 1) "c" 2) "4" 3) "e" 4) "9"
-
zcard key
返回元素个数
-
zcount key min max
返回[min,max] 区间内元素的数量
6. Hash data structure operation
-
hset key field value
作用: 把hash表中 filed域的值设为value 注:如果没有field域,直接添加,如果有,则覆盖原field域的值
-
hmset key field1 value1 [field2 value2 field3 value3 …… fieldn valuen]
作用: 设置field1->N 个域, 对应的值是value1->N (对应PHP理解为 $key = array(file1=>value1, field2=>value2 ....fieldN=>valueN))
-
hget key field
作用: 返回key中field域的值
-
hmget key field1 field2 fieldN
作用: 返回key中field1 field2 fieldN域的值
-
hgetall key
作用:返回key中,所有域与其值
-
hdel key field
作用: 删除key中 field域
-
select key
作用: 返回key中元素的数量
-
hexists key field
作用: 判断key中有没有field域
-
hincrby key field value
作用: 是把key中的field域的值增长整型值value
-
hincrby float key field value
作用: 是把key中的field域的值增长浮点值value
-
hkeys key
作用: 返回key中所有的field
-
whale key
作用: 返回key中所有的value