search

Home  >  Q&A  >  body text

redis - 频繁访问数据库内容。怎么做优化(或者说怎么做)。

我在做个Blog,现在涉及到配置信息要频繁访问数据库,现在该怎么做。或者使用(redis)。
下面是大概每次网页页面需要的数据。(这些数据后台要变动,不可以写死)。

  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `title` varchar(100) DEFAULT NULL COMMENT '网站标题',
  `keywords` varchar(255) DEFAULT NULL COMMENT 'SEO 关键字',
  `description` varchar(255) DEFAULT NULL COMMENT 'SEO  网站描述',
  `favicon` varchar(255) DEFAULT NULL COMMENT '网站 ICO 图标',
  `logo_img` varchar(255) DEFAULT NULL COMMENT '网站LOGO 地址',
  `theme_path` varchar(255) DEFAULT NULL COMMENT '主题路径',
  `domain_name` varchar(255) DEFAULT NULL COMMENT '网站域名',
  `page_view` int(20) NOT NULL COMMENT '网站访问量',
曾经蜡笔没有小新曾经蜡笔没有小新2793 days ago796

reply all(3)I'll reply

  • 黄舟

    黄舟2017-04-27 09:04:17

    These are configurations that rarely change. They can be loaded into the memory when the system starts. Then the code directly accesses the data in the memory (equivalent to the heap cache), and then provides a manual or scheduled update mechanism to retrieve the data from the database. Just update to cache.

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-04-27 09:04:17

    Do redis cache

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-04-27 09:04:17

    Basically, load the immovable information directly into the memory. If you don’t want to put it in the memory, use redis hash. No matter which way, just do the data synchronization.
    If the database is modified, the memory or redis must be updated in time.

    reply
    0
  • Cancelreply