There are many comments on the Internet that the efficiency of hashget/hashset is higher than get/set, and it is recommended to use hash as much as possible when using redis.Use less get/set key values.Here is a simple comparison of the performance of hashset and set, with data insertion executed 1000 times each:
$redis = new Redis(); $redis< span class="pun">->connect /p>
Obviously, when fetching data, hashget is faster than get.In general, hash is faster when reading data and slow when storing data.Therefore, in actual use, you should consider whether you read more or less in your business.
If it is set once like a cache, it will only be updated once for a long time, it is recommended to use hash.
If the data is updated very frequently, consider using set/get.