Unzip the tar package, using the following command
TAR-ZXVF redis-4.0.6.tar.gz
3. Install and build Redis using the following command
CD redis-2.6.14
Make Prefix=/usr/local/redis Install
You may encounter the following error during execution:
>> Tip 1:
MAKE[3]: gcc: Command not found
>> Solutions
Yum-y Install gcc-c++
>> Tip 2:
In a file that contains self-adlist.c:34:
ZMALLOC.H:50:31: Error: jemalloc/jemalloc.h: no file or directory
Zmalloc.h:55:2: Error: #error "Newer version of Jemalloc required"
>> Solutions
Add the MALLOC=LIBC parameter when make
Make Prefix=/usr/local/redis malloc=libc Install
Sign in to Redis
04Redis Basic command Redis's keys command
Keys * Query All
Keys Home Exact Search
Keys h* Fuzzy Lookup
DEL Key
This command is used to remove key when a key is present.
DUMP Key
Serializes the given key and returns the serialized value.
EXISTS Key
Checks if a given key exists.
EXPIRE Key seconds
Sets the expiration time for a given key.
Expireat key Timestamp
The Expireat function is similar to EXPIRE and is used to set the expiration time for the key. The difference is that the time parameter accepted by the Expireat command is a UNIX timestamp (Unix timestamp).
Pexpire key milliseconds
Sets the expiration time of the key in milliseconds.
Pexpireat Key Milliseconds-timestamp
Set the timestamp for key expiration Time (Unix timestamp) in milliseconds
KEYS pattern
Finds all keys that match the given pattern (pattern).
MOVE Key db
Moves the key of the current database into the given DB.
PERSIST Key
When the key expires, key will persist.
Pttl Key
Returns the remaining expiration time of key in milliseconds.
TTL Key
Returns the remaining lifetime (TTL, Time to live) for a given key, in seconds.
Randomkey
Returns a key randomly from the current database.
RENAME Key Newkey
Change the name of the key
Renamenx Key Newkey
Rename the key to Newkey only if the Newkey does not exist.
TYPE Key
Returns the type of value stored by key.
Redis string command
|
1 |
set key value
Sets the value of the specified key |
|
2 |
get key
Gets the value of the specified key. |
|
3 |
getrange key start end
Returns the substring of the string value in key |
|
4 |
getset key value
Sets the value of the given key to value and returns the old value of the key |
|
5 |
getbit key offset
Gets the bitwise (BIT) on the specified offset for the string value stored by key. |
|
6 |
Gets the value of all (one or more) given key. |
|
7 |
setbit key offset value
Sets or clears a bit (bit) on the specified offset for the string value stored by key. |
|
8 |
setex key seconds value
Associates the value of values to key and sets the expiration time of key to seconds (in seconds). |
|
9 |
setnx key value
Sets the value of key only if the key does not exist. |
|
10 |
setrange key offset value is used to overwrite the string value stored by the key with the value parameter, starting with offsets offset. |
|
11 |
strlen key returns the length of the string value stored by key. |
|
12 |
mset key value [key value ...]
Set one or more key-value pairs at the same time. |
|
13 |
msetnx key value [key value ...]
Sets one or more key-value pairs at the same time, if and only if all of the given keys do not exist. |
|
14 |
psetex key milliseconds value
This command is similar to the Setex command, but it sets the lifetime of the key in milliseconds, rather than in seconds, as in the Setex command. |
|
15 |
incr key
increases the number of values stored in key by one. |
|
16 |
incrby key increment
Adds the value stored by key to the given increment value (increment). |
|
17 |
incrbyfloat key increment adds the value stored by key to the given floating-point increment value (increment). |
|
18 |
decr key
Minus one of the numeric values stored in key. |
|
19 |
decrby key decrement
Key stores the value minus the given decrement value (decrement). |
|
20 |
APPEND Key value
If the key already exists and is a string, the APPEND command appends value to the end of the original value of the key. |