Home  >  Article  >  Database  >  Can redis only store strings?

Can redis only store strings?

(*-*)浩
(*-*)浩Original
2019-11-23 10:24:284893browse

Can redis only store strings?

Redis supports five data types: string (string), hash (hash), list (list), set (set) and zset (sorted set: Yes sequence set).

# STRING (String) (Recommended Learning: Redis Video Tutorial )

## String is the most basic type of Redis, you can It is understood to be exactly the same type as Memcached, with one key corresponding to one value.

The string type is binary safe. This means that the string of redis can contain any data. For example, jpg images or serialized objects.

The string type is the most basic data type of Redis. The string type value can store up to 512MB.

Hash (Hash)

Redis hash is a collection of key-value (key=>value) pairs.

Redis hash is a mapping table of string type fields and values. Hash is particularly suitable for storing objects.

List (List)

Redis lists are simple lists of strings, sorted in insertion order. You can add an element to the head (left) or tail (right) of the list.

Set (set)

Redis’ Set is an unordered collection of string type.

Sets are implemented through hash tables, so the complexity of adding, deleting, and searching is O(1).

zset (sorted set: ordered set)

Redis zset, like set, is also a collection of string type elements, and duplicate members are not allowed.

The difference is that each element is associated with a double type score. Redis uses scores to sort the members of the collection from small to large.

The members of zset are unique, but the scores can be repeated.

For more Redis-related technical articles, please visit the

Introduction to Using Redis Database Tutorial column to learn!

The above is the detailed content of Can redis only store strings?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Can redis store objects?Next article:Can redis store objects?