A
A
Albert Kazan2019-03-15 17:43:10
PHP
Albert Kazan, 2019-03-15 17:43:10

How to store an associative array in redis?

I read in the guides that you can store a bunch of everything in redis, and even there seemed to be a point that associative arrays are possible. However, it gives an error and I managed to save so far only in a JSON string. That would be enough, but with Russian characters the length of the string becomes 4 times longer and takes up 4 times more memory.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2019-03-15
@melkij

An associative array is a hash, respectively a group of commands for this data type: https://redis.io/commands/hgetall
(looking at the tags) For example phpredis are implemented

V
Vitaliy Orlov, 2019-03-15
@orlov0562

example from here

$redis->hMSet('user:1', array('name' => 'Joe', 'salary' => 2000));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question