redis搜索联想缓存方案设计

redis搜索联想缓存方案设计

欢迎关注作者博客
简书传送门

页面原型

redis搜索联想缓存方案设计

缓存词库

redis搜索联想缓存方案设计

redis搜索联想缓存方案设计

说明:

  1. 建议所有的请求都走异步调用
  2. 常用搜索词库数据统计规则:
    每天晚上12点定时取出所有人词库中排名靠前10位的搜索项并放入常用搜索库中
  3. 分数值=原有分数值*1.01+1.01
    分数值初始值为0
    分数值为浮点类型,两位小数
数据库
drop table if exists sc_search_common;

/*==============================================================*/
/* Table: sc_search_common                                      */
/*==============================================================*/
create table sc_search_common
(
   thesauruscommonid    int(64) not null auto_increment comment '主键id',
   key                  char(100) comment '键',
   score                float(10,2) comment '分数',
   updaterid            int(64),
   createrid            int(64),
   createtime           datetime,
   updatetime           datetime,
   state                int(3) comment '0-正常,1-禁用',
   creater              char(16),
   updater              char(16),
   primary key (thesauruscommonid)
);

alter table sc_search_common comment '常用词库存储表';

drop table if exists sc_search_history_user;

/*==============================================================*/
/* Table: sc_search_history_user                                */
/*==============================================================*/
create table sc_search_history_user
(
   searchhistoryuserid  int(64) not null auto_increment comment '主键id',
   userid               int(64) comment '用户id',
   key                  char(100) comment '键',
   score                float(10,2) comment '分数',
   updaterid            int(64),
   createrid            int(64),
   createtime           datetime,
   updatetime           datetime,
   state                int(3) comment '0-正常,1-禁用',
   creater              char(16),
   updater              char(16),
   primary key (searchhistoryuserid)
);

alter table sc_search_history_user comment '个人常用搜索词库';
主从冗余方案
  • redis词库存储采用持久化机制,并同时每天晚上12点定时更新常用词库内容;
  • 同时采用主从备份方案,鉴于线上服务器的稳定性与安全性,本次主服务器使用66服务器,43(云南服务器)作为备用服务器,并进行集群配置,进行数据实时同步。

欢迎加入Java猿社区
redis搜索联想缓存方案设计