Reprinted in: http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/96.html?1455870708 1.
A brief introduction to
redis Redis is a member of the NoSql family, an in-memory database of key-value pairs. But it supports saving data to local. This is better than memcached.
Disadvantages: No local data buffering, no complete data aggregation support yet.
Advantages : Simple configuration, ease of use, high performance, support for different data types (
hashes , lists, sets, sorted sets) the cache
Second, install the
unofficial version of the windows version. But "maintained by the Microsoft team" is the official statement. Download, decompress and run the
official Linux version of the server. The specific installation is also very simple.
Copy code as follows:
$ wget http://download.redis.io/releases/redis-2.8.17.tar.gz
$ tar xzf redis-2.8 .17.tar.gz
$ cd redis-2.8.17
$ make
3. Common commands
set key value insert key
get key get value
keys * query all keys
del key delete key
flushall
Commands related to clearing database connection operations
quit: close the connection (connection)
auth: simple password authentication
Persistence
save: synchronously save data to disk
bgsave: asynchronously save data to disk
lastsave: return the last successful data saved to disk Unix timestamp
shundown: save data synchronously to disk, then shut down the service
remote service control
info: provide server information and statistics
monitor: dump received requests in real time
slaveof: change replication policy settings
config: configure Redis server
at The command of value operation
exists(key): confirms whether a key exists
del(key): deletes a key
type(key): returns the type of the value
keys(pattern): returns all keys that satisfy the given pattern
randomkey: randomly returns the key space a
keyrename(oldname, newname): rename the key
dbsize: return the number of keys in the current database
expire: set the active time of a key (s)
ttl: get the active time of a key
select(index): query by index
move(key, dbindex): move the key in the current database to the dbindex database
flushdb: delete all keys in the currently selected database
flushall: delete all keys in all databases The command for key
to String operation
set(key, value): assign a value to the string named key in the database value
get(key): return the value of the string named key in the database
getset(key, value): give the name key The string is given to the last value
mget(key1, key2,..., key N): Returns the value of multiple strings in the library
setnx(key, value): Adds a string, the name is key, and the value is value
setex(key, time, value): add a string to the library, set the expiration time time
mset(key N, value N): set the value of multiple strings in batches
msetnx(key N, value N): if all strings named key i do not exist
incr(key): increment the string named key by 1
incrby(key, integer): increment the string named key by integer
decr(key): the string named key minus 1 operation
decrby(key, integer): the string named key is reduced by integer
append(key, value): the value of the string named key is appended value
substr(key, start, end ): return the substring
of
named key rpush(key, value): add an element whose value is value to the end of the list named key lpush(key, value): add an element named key to the end of the list
named key Add an element whose value is value to the head of the list
llen(key): returns the length of the list named key
lrange(key, start, end): returns the element between start and end in the list named key
ltrim(key, start, end): intercept the list
named key lindex(key, index): return the element at the index position in the list named key
lset(key, index, value): assign a value to the element at the index position in the list named key
lrem(key, count, value): delete the element whose value is value in the list of count keys
lpop(key): return and delete the first element in the list named key
rpop(key): return and delete the one named key tail element in list
blpop(key1, key2,… key N, timeout): The block version of the lpop command.
brpop(key1, key2,… key N, timeout): The block version of rpop.
rpoplpush(srckey, dstkey): Returns and deletes the tail element of the list named srckey, and adds the element to the head of the list named dstkey The command
for Set operation sadd
(key, member): to the list named key Add an element to the set member
srem(key, member): delete the element in the set named key member
spop(key): randomly return and delete an element in the set named key
smove(srckey, dstkey, member): move to Set element
scar(key): Returns the cardinality of the set named key
sismember(key, member): Whether member is an element of the set named key
sinter(key1, key2,…key N): Find the intersection
sinterstore(dstkey, ( keys)) : finds the intersection and saves the intersection to the set of
dstkeys sunion(key1, (keys)) : finds the union
sunionstore(dstkey, (keys)) : finds the union and saves the union to the set of dstkeys
sdiff(key1, (keys)) : find the difference
sdiffstore(dstkey, (keys)) : find the difference and save the difference to the set of
dstkey smembers(key) : return all elements of the set named key
srandmember(key ) : Randomly returns an element of the set named key Commands
for Hash operations
hset(key, field, value): Add an element field to the hash named key
hget(key, field): Return to the hash named key The value corresponding to field
hmget(key, (fields)): Returns the value corresponding to field i in the hash named key
hmset(key, (fields)): Add the element field
hincrby(key, field, integer): increase the value of the field in the hash named key by integer
hexists(key, field): whether there is a field with the key field in the hash named key
hdel(key, field): delete the key in the hash named key
hlen(key): returns the number of elements in the hash named key hkeys (key): returns
all keys in the hash named key
hvals(key): returns the value corresponding to all keys in the hash named key
hgetall(key): Returns all keys (fields) and their corresponding values in the hash named key
Redis Notes, Installation and Common Commands
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326996322&siteId=291194637
Recommended
Ranking