Home  >  Q&A  >  body text

mysql的标签(tag)是如何储存的?

请看这个页面:https://segmentfault.com/tags
可以看到,标签被分类了。
是否可以根据这个页面,认定segmentfault一定有tag_categorys表?
还是没有tag_category,只是在前端渲染的时候用了一堆堆的if?或者这个页面压根就是静态写的?那又如何反映tag的热门度呢?

阿神阿神2742 days ago916

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 14:48:34

    It stores a PHP array

    tags.php

    
    return [
        [
            'iOS 开发' => ['ios', 'iphone', 'ipad', 'objective-c', 'sqlite', 'safari'],
             'Android 开发' => ['android', 'java', 'eclipse', 'xml'],
        ],
        [
             '开发语言' =>  ['java', 'c', 'c++', 'php']
        ],
    ];
    

    Then the data is stored in redis, and user access is to retrieve data from redis.
    Of course, it is also possible to put it in MySQL, but these data do not change frequently, and there are many data categories related to tags. Using MySQL requires many tables, so the file management method is currently used.

    reply
    0
  • 迷茫

    迷茫2017-04-17 14:48:34

    The tag data will eventually be implemented. It should be stored in the MySQL table, and then the frequently used attributes will be cached in redis.

    As long as the question is associated with the tag_id, why do you need a tag to associate the issue?

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 14:48:34

    Maybe the redis set is used

    reply
    0
  • Cancelreply