我正在尝试通过使用 HMSET 将 redis 与多维数组一起使用。
我的阵列看起来像这样。
Array
(
[t] => Hello
[a] => This
[c] => key
[b] => 23
[data] => Array
(
[1] => some value
[more] => value
)
)
有什么方法可以使用 predis 库将这种格式的数据存储在 redis 中。
最佳答案
更好的方法是通过 json_encode
在 PHP 中将数组存储为 set 在 Redis 中
$string = json_encode(Array
(
[t] => Hello
[a] => This
[c] => key
[b] => 23
[data] => Array
(
[1] => some value
[more] => value
)
));
关于php - 在 php 中使用多维数组的 Redis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10664394/