目前我的想法是把访问量,关注数等先存到ssdb中(使用ssdb的incr操作),当访问数量%100 == 0 的时候,再将数据存储到数据库中。
大家有什么经验可以共享吗?
--------------更新----------
存储方面大致知道怎么做了,问题是因为有很多数据都缓存在ssdb中(比如关注数,访问量,粉丝数等等大概十个字段),如果想要获取某个用户的最新数据的时候,得从ssdb中读取多次(有些时候会在5-7次),这样的话读性能会不会下降的很厉害?
---------------更新----------
ssdb的API不够熟练。使用ssdb的zset来存储每个用户的信息,即可一次获取到一个用户的所有信息
PHPz2017-04-17 14:23:14
"Optimize" is approximately equal to "add cache", so you are doing the right thing. As for when to write data from cache to database, this can be weighed again.
巴扎黑2017-04-17 14:23:14
Tell us about our previous solution.
We use memecache, so for example, likes will generate a cache based on the id of your likes. Only when the number of likes exceeds a threshold will it be written to the database.
ringa_lee2017-04-17 14:23:14
Redis is more suitable for data such as visits, followers, views, and likes. The performance of Redis for data caching within 100K is higher than that of memcached