nosql, redis, performance test, the relevant command, Redis data type string, list, hash, set, zset,

nosql not only sql

User portrait:

Hot data: data is often used

mysql

installation

  • Yum can be used to install, configure the first source epel

     yum install -y redis
  • You can compile and install

     wget http://download.redis.io/releases/redis-5.0.5.tar.gz
     tar xf redis-5.0.5.tar.gz
     cd redis-5.0.5/
     make
     make test
     yum install -y tcl

redis executable file

 redis-Benchmark   # performance test 
 redis-the Check-aof   # Check and repair the aof file
 redis-the Check-rdb   # Check and repair the rdb file
 redis-cli         client # redis of
 redis-sentinel   cluster # redis of
 redis-server     server # redis of
 redis -trib.rb     # cluster management

Start redis

 ./src/redis-server default port is 6379, the default startup will occupy terminal

Performance Testing

 ./src/redis-benchmark -q
 PING_INLINE: 73855.24 requests per second
 PING_BULK: 73800.73 requests per second
 SET: 74074.07 requests per second
 GET: 72833.21 requests per second
 INCR: 73637.70 requests per second
 LPUSH: 73855.24 requests per second
 RPUSH: 70175.44 requests per second
 LPOP: 72202.16 requests per second
 RPOP: 74183.98 requests per second
 SADD: 74962.52 requests per second
 HSET: 75642.96 requests per second
 SPOP: 73746.31 requests per second
 LPUSH (needed to benchmark LRANGE): 74850.30 Requests per SECOND
 LRANGE_100 (First 100 Elements): 48379.30 Requests per SECOND
 LRANGE_300 (First 300 Elements): 24172.11 Requests per SECOND
 LRANGE_500 (First 450 Elements): 18670.65 Requests per SECOND
 LRANGE_600 (First 600 Elements): 15384.62 Requests per SECOND
 MSET ( Keys 10): 78186.08 Requests per SECOND,
 default is 100000,50 initiate simultaneous connections

connection

 ./src/redis-cli 
 -h ip address
 -p port
 -s socket
 -a password  
 -n designated library redis
 redis commands are not case sensitive

redis data types

  • string

  • hash

  • list

  • set

  • token

Related command

ping

Redis used to test whether the communication, the return value is pong

info

Access to information systems

echo

Print content, test use

quit

drop out

select

Switching redis library, a total of 16, 0-15

of the

One or more key to delete the specified, non-existent key ignored

exists

Determining whether there is a key, the presence of a 1, 0 is not present

expire key seconds

The key to the specified settings survival time, when after the key expires, it is automatically deleted

ttl

View key survival time, -2 key -1 permanent does not exist

keys pattern

Find all meet the pattern of the key, support wildcards

move key db

Key to move the current designated db inside, a successful return, else return 0

pexpire key ms

A key to set the expiration time, in milliseconds

pttl key

View key survival time, but in milliseconds

randromkey

Gets a random key, but does not remove, if the database is empty, then return empty

rename

Rename key, if the source key does not exist, the error, if the target key is present, the cover

renamenx

Rename the key, if the source key does not exist, an error, if the target key is present, unchanged

type

View key type of data stored, if not the key, then none return

string

set

Set key value

If the key is present, the coverage does not exist, the new

ex second set key survival time, in seconds

px ms set key of the survival time, in milliseconds

nx If the key does not exist, create a new, if present, nil is returned

xx key exists only in order to operate

get

Obtaining corresponding key value, only get one, if the key is present, the return value, if the key does not exist, it returns nil

mset

Bulk create key vlaue correspondence, it will overwrite an existing key

mget

Batch acquire key, if you do not exist, nil is returned

GetSet

To the designated key to set a new value, and return to the original value, if the key does not exist, returns nil

strlen

Returns the value of the length

append

If the key is present, append, if the key does not exist, the new

incr

The key plus one exists, can only be effective for digital

decr

The present key value minus 1, only valid digital

incrby

The value of the specified key exists to increase the number of valid only for digital

decrby

The present key number by the specified value, only effective digital

getrange

Slice, similar with python, you can not use step

incrbyfloat (default retention 17)

The key present in the specified floating-point value increases

list

lpush

One or more of the value inserted at the head of the list

lpop

Removes and returns the first element of a list of key

lrange

View a list of specified elements, it shows all 0, -1

rpush

One or more of the value inserted at the tail of the list (the last edge)

rpop

Delete the value of the tail

rpushx

The key value is inserted into the tail, key must exist before they can

lpushx

The value is inserted into the key head, key must exist before they can

lindex

Starting from the header, obtaining the index value of the subscript

linsert

After the specified key value is inserted into the front element or

before 前

After after

If the value does not exist, no action

len

Get a list length

LRMS

Delete the list value

  • count> 0 toward the end of the table from the lookup table header, delete the specified number of

  • count = 0 Remove all

  • count <0 toward the header from the position of the tail of the lookup table, delete the specified number

lset

Alternatively index location specified value, if the index is out of range, an error

LTrim

Slice list

hash

{'db':{"redis":'redis.conf',"mysql':'my.cnf',"nginx":"nginx.conf"}}

hset

To increase key value hash value

choose

Get the length of the hash

hget

Gets a hash key inside the value

hgetall

Get all the key-value pairs

hmset

Batch Add key-value pairs

hmget

Batch obtain key-value pairs

hsetnx

To increase the specified hash key value pairs, if the original field is present, the operation is invalid, and if not, then add

hkeys

Gets the hash table of all field

whales

Gets the value of all the hash table

hdel

One or more field-value hash table delete

hexists

The hash table is determined whether there is a field, if present, was 1, there was 0

hincrby

Hash table to increase the value of the field specified, limited numbers

hincrbyfloat

To hash table field specified floating-point increase, it is limited to digital

set

sadd

Adding value to the collection, if the value is present, nothing operation, if the value does not exist, add

SMEMBERS

Get all the members of a collection

scard

Gets the number of collection

sdiff

Obtaining a difference set of the two sets, the presence of the front, back but does not exist

sinter

Gets intersection of two sets

sunion

Obtain and set two sets of

SISMEMBER

Determining whether the elements in the set, if present, was 1, and 0 if there is no

smove

Elements from a specified set of mobile to another set, if the source set exists, the mobile, and if not, is ignored if the target set is present, direct movement, if the object set does not exist, and create a new set of moves

spop

Remove elements specified number of random and delete elements of the print

SRANDMEMBER

Get the number of elements specified random

  • Gets a random default

  • If the count> 0,

    • If the count is greater than the total number of set, then remove all

    • If the count is less than the total number of the set, then a count taken randomly

  • If count <0, the absolute value of the random count value extracted twice

srem

Delete the specified one or more elements

 

Guess you like

Origin www.cnblogs.com/zhang-da/p/12417705.html