比方说每条数据需要相关用户的信息,是存放user_id,每次读取时都去获取最新的用户信息,还是直接存放user对象的实际数据?
是时间换空间,还是空间换时间?
好纠结啊,大家一般怎么操作?
迷茫2017-04-28 09:08:33
If the user information will be updated, the user_id must be stored and then obtained separately (usually it has been obtained when the user logs in and cooperates with redis for storage calls). Also, do not ignore the storage read speed of mongodb. This is mongodb The advantage lies in. Personally speaking, all my projects store users separately and then call them through user id. for reference only.
淡淡烟草味2017-04-28 09:08:33
It is indeed difficult to measure with a standard
If you want to combine multiple tables, it will be a bit troublesome because it is an asynchronous operation.
If you change relatively mundane data, use ID to associate it
漂亮男人2017-04-28 09:08:33
Of course you save the ID. Logically speaking, if the user logs out/is deleted/reported/has illegal content, but what you save is the actual data, how do you modify it then?