X
X
xynbka2021-11-22 15:38:53
Redis
xynbka, 2021-11-22 15:38:53

Is it possible to add extra fields to Json in Redis by key?

I cache the following json structure in Redis
key: id
value: (JSON)
{ accounts : [{ name: 1, value: 354}, { name: 2, value: 234}, ...]
cards: [{ number : 234, type : mastercard }, ...]
}

I get the accounts and cards values ​​from different services. The entity stored in Redis is described in ProtoBuf. Interested in the question. Is it possible to add the Redis value to the cards field in Json after the responses from the service? If not, what are the best practices on this subject? Or would the easiest option be to get accounts - write to the cache, throw the entity into the next method, add cards and overwrite the value in redis?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Tikhonov, 2021-11-22
@tumbler

Firstly, there is RedisJSON , and secondly, depending on the needs of the application, this data can be decomposed into lists, hashes, sorted sets, and any other combination of native radish data types. And thirdly, no one bothers to work with JSON data as a string (get, deserialize, insert, serialize, save).
It all depends on how the stored data is used.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question