Redis inserting out of order, or sorting oddly?

前端 未结 1 979
南笙
南笙 2021-01-21 03:55

I have some code written like this:

foreach ($models as $model) {
    Redis::hset(\'model_App\\ServiceModel\', $model[$primaryKey], json_encode($model->toArra         


        
相关标签:
1条回答
  • 2021-01-21 03:58

    Redis' Hashes are unordered - that is the expected behavior. If sorting is needed, either look into using Sorted Sets, the SORT command, or (preferably) sorting the data in the client.

    0 讨论(0)
提交回复
热议问题