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

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

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

相关推荐
m0_612535994 小时前
redis入门到精通
数据库·redis·缓存
刘~浪地球5 小时前
Redis 从入门到精通(三):键操作命令详解
数据库·redis·缓存
刘~浪地球7 小时前
Redis 从入门到精通(四):字符串操作详解
数据库·redis·缓存
xhuiting8 小时前
Redis专题(二)
redis·缓存
zlp199211 小时前
软考(系统架构师)-案例分析之Redis与缓存
redis·缓存·软考高级·软考·系统架构师
小雨青年12 小时前
当缓存成为生产力:GitHub Actions 缓存机制的深度优化指南
缓存·github
山檐雾12 小时前
C#泛型缓存
缓存·c#
星夜泊客13 小时前
《Lua 模块化核心:require 的地址传递与缓存机制》
缓存·lua
ofoxcoding13 小时前
Redis 缓存穿透怎么解决?3 种方案实测 + 踩坑全记录(2026)
数据库·redis·缓存·ai
bLEd RING1 天前
Redis 设置密码无效问题解决
数据库·redis·缓存