Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Database \ Redis data types Introduction     - To create a full command line Android Build System (Linux)

- STL spatial Configurator (Programming)

- Linux command to view the system status (Linux)

- Ubuntu 14.10 installation GNOME 3.14 (Linux)

- Linux protobuf-c (Linux)

- Secondary exponential smoothing prediction method implemented in Python (Programming)

- Android Studio simple setup (Linux)

- Docker: Mirroring and container operations (Server)

- CentOS 6.6 source compiler GCC upgrade to 4.8.2 (Linux)

- The direct insertion sort algorithm (Programming)

- RHEL7 unattended automatic installation DHCP + TFTP + SYSLINUX + TFTP + Kickstart (Linux)

- C ++ Supplements - References (Lvalue Reference, Rvalue Reference) (Linux)

- Zabbix installation under Linux (Server)

- Installation and use Docker under Ubuntu 14.04 (Linux)

- Spring classic face questions Share (Programming)

- How to create a secure and easy to remember password (Linux)

- MySQL management partition table (Database)

- Thinking in Java study notes - initialization and cleanup (Programming)

- ActiveMQ-based shared file system HA solutions (Server)

- Encounter ORA-00600: internal error code, arguments: [4194] ORA-1552 (Database)

  Redis data types Introduction
  Add Date : 2017-01-08      
  Redis supports five data types: string (string), hash (hash), list (list), set (set) and zset (sorted set: ordered set).

String (String)

redis string is the most basic type, you can understand exactly the same type as with Memcached, a key corresponding to a value.

string type is binary safe. Meaning redis the string can contain any data. Such as jpg image or a sequence of objects.

Redis string type is the basic data types, a key can be stored maximum 512MB.


redis> SET name "shouce.ren"
redis> GET name
In the example above we use Redis of SET and GET commands. Key is name, the corresponding value shouce.ren.

Note: A key can store maximum 512MB.

Hash (hash)

Redis hash is a collection of key-value pairs.

Redis hash is a string type of field and value mapping table, hash is particularly suitable for storing objects.


redis> HMSET user: 1 username shouce.ren password shouce.ren points 200
redis> HGETALL user: 1
1) "username"
2) "shouce.ren"
3) "password"
4) "shouce.ren"
5) "points"
6) "200"
Examples of the above data types stored in the hash of the user object that contains user scripts. Examples we use Redis HMSET, HEGTALL command, user: 1 as key.

Each hash can be stored 232--1 value pairs (4000000000).

List (list)

Redis list is a simple list of strings sorted insertion order. You can add a header element guide list (on the left) or rear (on the right).


redis> lpush shouce.ren redis
(Integer) 1
redis> lpush shouce.ren mongodb
(Integer) 2
redis> lpush shouce.ren rabitmq
(Integer) 3
redis> lrange shouce.ren 0 10
1) "rabitmq"
2) "mongodb"
3) "redis"
List can store up 232--1 element (4,294,967,295 each list can store more than 4 billion).

Set (collection)

Redis is an unordered collection of Set string type.

Set by the hash table to achieve, so add, delete, find the complexity is O (1).

sadd command

Adding to a string element, key corresponding set collection, successful return 1, and returns 0 if the element in the collection, key corresponding to the set does not exist an error is returned.

sadd key member

redis> sadd shouce.ren redis
(Integer) 1
redis> sadd shouce.ren mongodb
(Integer) 1
redis> sadd shouce.ren rabitmq
(Integer) 1
redis> sadd shouce.ren rabitmq
(Integer) 0
redis> smembers shouce.ren
1) "rabitmq"
2) "mongodb"
3) "redis"
Note: The above example rabitmq added twice, but based on a unique set of elements within the second insertion element is ignored.

The maximum number of members in the collection of 232--1 (4294967295 Each set can store more than 40 million members).

zset (sorted set: an ordered collection)

Redis zset and is set as a collection of elements of type string, and does not allow duplicate members.

The difference is that are associated with each type of element of a double score. It is through redis scores for small to large order of collection members.

Zset member is unique, but the score (score) it can be repeated.

zadd command

Add an element to the collection, the element is present in the collection updates the corresponding score

zadd key score member

redis> zadd shouce.ren 0 redis
(Integer) 1
redis> zadd shouce.ren 0 mongodb
(Integer) 1
redis> zadd shouce.ren 0 rabitmq
(Integer) 1
redis> zadd shouce.ren 0 rabitmq
(Integer) 0
redis> ZRANGEBYSCORE shouce.ren 0 1000
1) "redis"
2) "mongodb"
3) "rabitmq"
Hello World
- Python type way of comparison (Programming)
- How to upgrade the kernel to 3.13.7 on Ubuntu / Linux Mint (Linux)
- HashMap in Android and Java different implementations (Programming)
- Zabbix installation and configuration process (Server)
- Vagrant build LNMP environment (Server)
- Linux NIC configuration (Linux)
- Linux System Getting Started Learning: complete installation on Debian or Ubuntu kernel source (Linux)
- Oracle 11R2 Grid Infrastructure execute root.sh script rootcrs.pl execution failed treatment (Database)
- Oracle create a temporary table space group (Database)
- Linux program analysis tool: ldd and nm (Linux)
- Install the latest Pinta graphics editing software on Ubuntu 14.04 (Linux)
- How to use the TF / SD card making Exynos 4412 u-boot boot disk in Mac (Linux)
- MySQL 5.7 can not log in problem (Database)
- How to create a someone project on github (Linux)
- Novice Advanced Ubuntu7.10 configured IP address (Linux)
- dd command: do hard disk IO performance test (Linux)
- Setting the RedHat9 Intrusion Detection System (Linux)
- CentOS x86 64bit upgrade to 2.7 Python2.6 (Linux)
- Questions about Linux compiler u-boot (Programming)
- Linux Getting Started tutorial: Experience Xen Virtual Machine chapter (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.