redis - MySQL存储访问量,关注数等更新比较频繁的数据的时候,如何减轻数据库负担?
迷茫
迷茫 2017-04-17 14:21:14
0
4
701

目前我的想法是把访问量,关注数等先存到ssdb中(使用ssdb的incr操作),当访问数量%100 == 0 的时候,再将数据存储到数据库中。
大家有什么经验可以共享吗?
--------------更新----------
存储方面大致知道怎么做了,问题是因为有很多数据都缓存在ssdb中(比如关注数,访问量,粉丝数等等大概十个字段),如果想要获取某个用户的最新数据的时候,得从ssdb中读取多次(有些时候会在5-7次),这样的话读性能会不会下降的很厉害?
---------------更新----------
ssdb的API不够熟练。使用ssdb的zset来存储每个用户的信息,即可一次获取到一个用户的所有信息

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(4)
PHPzhong

"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.

巴扎黑

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.

左手右手慢动作

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

阿神

1.cache
2.MySQL read and write separation

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!