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

字典是软件开发中常用的功能。使用字典的核心问题是翻译,因为数据库中存储的是代码,前台页面展示的是描述。用于多语言环境时,翻译过程还需要根据语言环境进行适配。为了加快字典的加载速度,千里马平台采用了后台缓存+前台缓存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),没有的话从数据库中读取。

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

相关推荐
Lyyaoo.3 小时前
Redis基础
数据库·redis·缓存
rannn_1118 小时前
【Redis|原理篇2】Redis网络模型、通信协议、内存回收
java·网络·redis·后端·缓存
志飞10 小时前
springboot配置可持久化本地缓存ehcache
java·spring boot·缓存·ehcache·ehcache持久化
下地种菜小叶11 小时前
行为采集、召回、排序、缓存怎么配合?一次讲透
缓存
chen_ever12 小时前
Redis详解|从基础到面试高频题
数据库·redis·后端·缓存
m0_7375393713 小时前
redis的安装
数据库·redis·缓存
yuezhilangniao14 小时前
Redis 哨兵高可用集群完整文档-容器部署reids集群
数据库·redis·缓存
rleS IONS16 小时前
Redis五种用途
数据库·redis·缓存
China_Yanhy16 小时前
[Infra/SRE 知识库] AWS CloudFront API 边缘缓存配置与排障复盘
缓存·云计算·aws
YQ_0117 小时前
大幅提速 colcon build —— ccache 缓存 + 并行数控制防爆内存
linux·缓存·机器人·ros2