Home  >  Article  >  Database  >  Can redis store objects?

Can redis store objects?

(*-*)浩
(*-*)浩Original
2019-11-23 10:13:274022browse

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)

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);

Option 2: Serialize to string

Use redis interface:

jedis.get(String key);
jedis.set(String key, String value);

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 Database column 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!

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