redis - 频繁访问数据库内容。怎么做优化(或者说怎么做)。
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-04-27 09:02:17
0
3
773

我在做个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 '网站访问量',
曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(3)
黄舟

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.

曾经蜡笔没有小新

Do redis cache

phpcn_u1582

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.

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!