Redis Daquan face questions with answers

Redis Daquan face questions with answers

Redis Daquan face questions with answers

1. What is Redis?
A: Remote Dictionary Server (Redis) is an open source use written in ANSI C, support network, based on the persistence of memory can log type, Key-Value database, and provides multi-lingual API.
It is often called a data structure of the server, since the value (value) can be a string (String), a hash (the Map), list (List), set (sets), and an ordered collection (sorted sets) and other types.

2.Redis features what is?
1. To support a variety of data structures, such as a string (string), List (doubly linked list), dict (hash table), SET (set), zset (ordered set), hyperloglog (cardinality estimate)
2. Support persistence operations, and can be aof rdb data persistence to disk, data backup or data recovery operations, means better prevent data loss.
3. Support for data replication via Replication,, can be synchronized copy data in real time via master-slave mechanism to support multi-level replication and incremental replication, master-slave mechanism is an important means to carry out Redis HA.
Single process requests, all commands executed serially, concurrent data consistency without the need to consider the issue.

3.Redis data types are there?
A: String (String)
Hash (hash table)
List (list)
the Set (collection)
SortedSet (ordered set zset)

4.Redis of frequently used commands what?
incr increments to let the current key number 1, and returns the value incremented
incrby can specify parameters once added value, and returns the value incremented
incrby can specify parameters once increased value, and a value after increment
value decrby parameters can be designated a decreasing numerical values, and decreasing the return
incrbyfloat a double-precision floating-point numbers may be incremented
append function is to append to the value of key. If the key does not exist then the key value is set to value. The return value is the total length of the string after appended.
mget / mset role and get / set similar, but mget / mset can be obtained at the same time / set multiple keys keys
del to delete a value according to Key
flushdb clear all data from the current database
hset store a hash set key-value pairs
hget acquisition a hash key value of
hmset store one or more hash is a collection of key-value pairs
hmget specified key values of a plurality of
field names hexists hash table to determine whether there exists returns 1 if otherwise it returns 0
HDEL delete a or more fields
hgetall to obtain a hash key value is set
hvals returns only the field value
hkeys only returns the field name
hlen returns the number of elements in the hash key
lpush key value is added to the left list
rpush key value is added to the right list
lpop key out to the left one element
rpop key element is removed from the right
llen key returns the number of elements in the list corresponds to the relational database select count (*)
lrange key start end lrange command returns all the element index from the start to the stop between. Redis list starting index is 0.
lrange also supports negative index lrange NN -1 -2 -1 as a first element represents the rightmost rightmost -2 is the second element, and so on.
lindex key indexnumber If you want to use an array as type list, lindex command is essential. lindex command to return the element to the specified index, from index 0 start
If negative number means the index is counted from the right, the right most element in the index is -1.
Lset key indexnumber value is another list of index operations command, it will assign the index for the element index to value.
sadd key value is added to a string element, set key corresponding to a collection, a successful return, if the element has been returned in the set 0
SCard key returns the number of elements in the set, if the set key does not exist or is empty return 0
smembers return key set key corresponding to all the elements, the result is disordered
sismember key value determines whether the value in the set, indicates the presence of 1,0 returned key does not exist or does not exist
to remove a given value corresponding to the key element Srem key set, a successful return 1, if the key value does not exist or does not exist in a set return 0
zadd key score value and one or more value added to the set of socre
zrange key start end 0 and -1 indicates an element index from 0 to the last elements (with LRANGE command similar)
zrange key 0 -1 withscores may be output along with a score, using the parameters WITHSCORES
zremrangebyscore key start end can be used to delete a range
ping test whether the link if the link redis return PONG
echo test value is linked redis If linked returned echo command given value
keys * key can be added to return all the * wildcard
eXISTS key type string is determined whether there is a key, if present, otherwise returns 1 0
the expire time key (S) to set the expiration time of a key in seconds. Deletes the key and value time after arrival
ttl key inquiry has set the expiration time of the key remaining time if the return of -2 indicates that the key has been removed
persist Removes the given key expiration time
select dbindex select the database (0-15)
move key dbIndex the current database of key transferred to other databases in
the number of dbsize return key in the current database of
info obtain the server information and statistics
key flushdb delete the currently selected database of
all flushall delete all database key
quit exit connection

5.Redis configuration and persistence there are several?
Two
RDB ways
AOF way

what is RDB way?
RDB is a memory snapshot of the database state
RDB manner: Redis database stored in the state memory to disk inside, RDB file is a compressed binary file, the state can restore the database RDB is generated by the document file (by default, to the persistent file dump.rdb, redis and after the restart, which automatically read the file, it is learned, usually the next ten million key string type, 1GB of snapshot files, the time synchronization memory is 20-30 seconds)
a RDB is generated by:
1, Run manually generate
two Redis commands can be used to generate the RDB files, one is SAVE, the other is bGSAVE SAVE command Redis server process will be blocked until the RDB file has been created so far, during the blocking process server, the server can not process any command request, bGSAVE command derive a child process, then the responsibility of the child process created RDB file server process (parent process) continues to process commands request, created before the end of the RDB file, bGSAVE and SAVE command sent by the client will be rejected by the server

2, automatically generated by the configuration
can set the save server configuration options, so service It is executed automatically at regular intervals BGSAVE command may be provided a plurality of storage conditions, but as long as a condition is satisfied by any of save option, the server will execute the command BGSAVE
example:
save 900. 1
save 300 10
save 60 10000
so long as any one of the following three conditions, the command will be executed bgsave
server 900 seconds, the database is at least one revision
server within 300 seconds, the database is modified at least ten times
the server within 60 seconds inside, the database is at least 10,000 times to modify

what is AOF way?
AOF persistent way in redis is off by default, need to modify the configuration file to open the way.
AOF: Each command written to the file, binlog mysql log similar to the
AOF way: write command to record the state of the database files executed by saving Redis server.
AOF file refresh the way, there are three:
appendfsync Always - each submitted a modified commands to call fsync refresh AOF file, very, very slow, but also very safe
appendfsync everysec - every second call to fsync refresh AOF file, quickly, However, data may be lost within one second
appendfsync no - rely on OS refresh, redis not take the initiative to refresh the AOF, so the fastest, but he sent security
default and recommended refresh every second, so the speed and security have done both
AOF data recovery mode
server at startup, saved by loading and executing AOF file command to restore the database state before the server shuts down, the specific process:
load AOF file
created simulation client
reads a command from the AOF file
using an analog customers end execute the command
loop reads and executes commands until completed
if RDB and AOF simultaneously enabled, AOF priority, only load when you start AOF file recovery data


Articles from www.wityx.com , please indicate the source! Original Address http://www.wityx.com/post/712_1_1.html

 

Guess you like

Origin www.cnblogs.com/Yanss/p/11725246.html
Recommended