Home > Database > Redis > What data should redis cache?

What data should redis cache?

(*-*)浩
Release: 2019-11-22 13:06:18
Original
2751 people have browsed it

What data should redis cache?

There are 5 types of Redis cache data types, namely String (string), List (list), Hash (hash), Set (unordered, non-repeating set) ), ZSet (sorted set: ordered, non-duplicate set).

String (string) (Recommended learning: Redis video tutorial)

The string type is the latest type of redis, a key Corresponds to a value.

The String type in Redis is binary safe and can contain any data. For example, serialized objects or pictures.

String type key can store up to 512M.

The assignment command for String type in Redis is SET, and the value command is GET.

List (list)

The Redis list type is a simple list of strings, sorted in insertion order.

Each List can store up to 232 - 1 elements (more than 4 billion).

The List type in Redis is assigned through the lpush command and obtained through the lrange command.

Set (unordered, non-repeating collection)

Redis’ set is an unordered and non-repeating collection type, an unordered collection of String type.

Add elements to the collection through the sadd command, and obtain the collection through the smembers command.

The maximum number of members in the set is 232 - 1 (more than 4 billion).

Sorted set (ordered, non-repeating set)

The ordered set in Redis is ordered but the elements in it are not repeated. It is an ordered set of String type.

Each element of zset will be bound to a double type value. The set is sorted in ascending order according to the value. The value can be repeated, but the value cannot be repeated.

Add elements to the collection through the zadd command. If the element already exists in the collection, update the corresponding double type value. Get the Sorted set collection elements through the ZRANGEBYSCORE command.

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 What data should redis cache?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template