千里马平台设计说明-字典缓存

字典是软件开发中常用的功能。使用字典的核心问题是翻译,因为数据库中存储的是代码,前台页面展示的是描述。用于多语言环境时,翻译过程还需要根据语言环境进行适配。为了加快字典的加载速度,千里马平台采用了后台缓存+前台缓存2级缓存机制。

以下代码摘自@/api/qlm_dictItem.js

复制代码
export async function gainCodeItemList(setid){
 let value=qlm_getValue(setid,"session")
 if (value!=null){
   return JSON.parse(value)
 }
 let ret=await queryCodeItemList(setid)
 if (ret.retCode==88888888){
   qlm_setValue(setid,JSON.stringify(ret.data),"session")
   return ret.data
 }
 else{
   console.info("gainCodeItemList:"+setid+" error:"+ret.msg)
   return null
 }
}

取字典时先从sessionStore中取(只所以存在sessionStore中是为了刷新方便),取不到时调用接口queryCodeItemList从后台取字典。

后台接收到请求时,先取缓存(根据配置取内存或redis),没有的话从数据库中读取。

维护字典信息时,需要实时刷新缓存。

相关推荐
三水不滴4 小时前
Redis 过期删除与内存淘汰机制
数据库·经验分享·redis·笔记·后端·缓存
ytgytg288 小时前
HC小区管理系统安装,提示redis连接错误
数据库·redis·缓存
Grassto10 小时前
11 Go Module 缓存机制详解
开发语言·缓存·golang·go·go module
he___H12 小时前
Redis高级特性
数据库·redis·缓存
crossaspeed12 小时前
Redis的持久化(八股)
数据库·redis·缓存
怡步晓心l13 小时前
Mandelbrot集合的多线程并行计算加速
c++·算法·缓存
三水不滴15 小时前
Redis 故障转移:哨兵vs集群
数据库·经验分享·redis·缓存·性能优化
鸽芷咕16 小时前
从 Query Mapping 到函数缓存,KingbaseES 高级 SQL 调优手段全揭秘
数据库·sql·缓存·金仓数据库
曹天骄16 小时前
基于 Cloudflare 的双层缓存架构实践:CDN Cache 与 Worker Cache 的职责分离设计
缓存·架构
Looooking17 小时前
Python 之 cachetools 缓存工具
缓存