Redis cache refresh configuration

Foreword: Whether it is development or production, there is an operation to refresh redis_key, but there is no unified place to manage the redis_key used by some businesses (sometimes even need to find code location), based on this thinking, a configurable refresh cache architecture is made

Core idea: based on operations and KV loading to achieve refresh in different strategies (the idea is simple but the implementation is relatively complicated, see the table creation statement for details)

Currently, dimensions are implemented based on string and hash common operations

Select a specific strategy update class according to four dimensions
 handle_type: operation type update/delete
 key_kind: string hash
 key_type: do not load through sql, 1 load value_type through sql
 : configuration value, sql query string data, sql query object saves object value, sql query saves list data

The following is the corresponding figure

 

Create table statement

drop table  if exists cache_fresh_bean;
create table cache_fresh_bean(
        id  int auto_increment primary key,
        key_kind    tinyint default 0 comment 'key的种类;0-string 1-hash',
        key_name   varchar(200) comment '缓存key',
        key_param text comment '拼接key的参数,逗号分割;',
        key_type tinyint default 0 comment '0-string不通过sql加载,1-string 通过sql加载;',
        value_param text comment '拼接key的参数,逗号分割;',
        value_type tinyint default 0 comment '0-不加载sql,1-加载sql string ,2-sql Object ,3 sql list',
        count_expression text comment 'sql统计表达式',
        select_expression text  comment 'sql查询表达式,不带limit,分页查会自动计算',
        page_status  tinyint default 0 comment '分页 0-使用默认limit 2000 1-使用select_expression表达式的 2-使用count_expression分页',
        expire_time int UNSIGNED comment 'key存活时间',
        expire_unit int comment '单位 TimeUnit中的 nanoseconds-纳秒  microseconds-微秒  milliseconds-毫秒  seconds-秒  minutes-分  hours-小时  days-天',
        status tinyint default 0 comment '0-未执行,1-正在执行 2-执行成功 3-执行失败',
        remark  text comment '备注' ,
        handle_type varchar(60) comment '刷新类型 0-删除 1-刷新',
        create_time datetime                                 default now() comment '创建时间',
        create_by   varchar(100) comment '创建人',
        update_time datetime                                 default now() ON UPDATE now() comment '更新时间',
        update_by   varchar(100) comment '更新人'
) comment 'redis常用配置_缓存刷新配置';

Guess you like

Origin blog.csdn.net/haohaounique/article/details/123973870