Home> Database> Redis> body text

Can redis store objects?

(*-*)浩
Release: 2019-11-23 10:13:27
Original
3920 people have browsed it

Can redis store objects?

Redis has been widely used, but redis itself does not have a method to directly store objects. We can store objects by converting them.

A rough summary of the following options:(Recommended learning:Redis video tutorial)

Option 1: The serialized object is Binary

Use redis interface:

jedis.get(byte[] key) jedis.set(byte[] key, byte[] value)
Copy after login

As for the serialization method, we have many choices, such as: Java serialize, Protobuf, or manual serialization by yourself

public byte[] serialize(Object obj); public Object unSerialize(byte[] bytes);
Copy after login

Option 2: Serialize to string

Use redis interface:

jedis.get(String key); jedis.set(String key, String value);
Copy after login

Serialize to string, we also have many choices : Json (Jackson, FastJson),

For more Redis-related technical articles, please visit the

Introduction Tutorial on Using Redis Databasecolumn to learn!

The above is the detailed content of Can redis store objects?. 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!