Database Reference
In-Depth Information
# Replication
role:master
connected_slaves:0
# CPU
used_cpu_sys:69.16
used_cpu_user:35.95
used_cpu_sys_children:0.00
used_cpu_user_children:0.00
# Keyspace
> db0:keys=1,expires=0,avg_ttl=0
The preceding output shows the results of the info command. Some of the
output has been omitted to save space, but there are some items of interest
that become useful when administering and monitoring a Redis instance.
Because Redis is a key-value store, the most basic commands are for setting
keys. Keys in the Redis world are generally considered to be string values,
even when they are being used to represent integer or floating-point values.
To set or get a key, use the SET <key> <value> and GET <key>
commands, respectively. If there are several keys to be set or retrieved in
a single call, then you can use the MSET <key1> <value1> <key2>
<value2> and MGET <key1> <key2> commands instead of issuing
multiple calls. In all cases, if a key does not exist the GET command and
its variants return a NULL value. If only an existence check is required, the
EXISTS command is also available. The existence command is usually used
in concert with Redis' scripting functionality, which is discussed later.
The next-most-complicated data structure in Redis is the hash table. This
form of key allows for the storage of subkeys similar to the Map collection
in Java or a Dictionary type in other languages such as JavaScript. Instead
of the simple GET and SET commands, you use HSET <key> <subkey>
<value> and HGET <key> <subkey> to access elements of the hash table
with HMSET and HMGET allowing for updates or retrieval of multiple subkeys
from a hash table. To retrieve all subkeys and their values, use HGETALL
with HKEYS and HVALUES retrieving all subkey names or subkey values
respectively.
Both normal keys and hash tables support atomic counters. For normal
keys, the INCR and INCRBY commands increment the value of the key by
Search WWH ::




Custom Search