Home  >  Q&A  >  body text

redis怎么处理mysql的关联数据?

mysql数据库中有A、B、C三张表,现在应用程序得到的数据是由这三张表关联查询后得到的结果集。
每个用户得到的关联查询结果是不一样的。
我想插入数据时就直接写入到redis,用户所有操作都在redis里面,定时把数据同步到mysql,但是redis不支持关联查询,redis如何返回mysql关联查询出的结果呢?

PHP中文网PHP中文网2741 days ago604

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 13:13:39

    If the related query is very close, it may be wrong to choose redis. It is more suitable to choose a product that supports conditional query, such as MongoDB;

    If it is not very close, query ABC separately to determine which table can get the smallest result set through the conditional filtering after where; then use this minimum result set to check the other two tables;

    In addition, redis supports intersection, but the time complexity is relatively high, and it may not be faster than filtering it yourself;
    http://redisdoc.com/set/sinter.html

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 13:13:39

    Can you use Map table storage?

    reply
    0
  • Cancelreply