Skip to content

前端字典缓存问题及优化建议 #145

Open
@beanww

Description

@beanww

const { wsCache } = useCache('sessionStorage')

前端字典缓存为什么用sessionStorage? 用localStorage不是也行么, 而且localStorage可以多个页签共享

且我验证了下使用的这个3rd的storage似乎有个问题:

wsCache.delete()只能清理localStorage的缓存内容,不能清理sessionStorage的

且此前端字典缓存还存在如下问题:

  1. 在退出登录时没有清理字典缓存
  2. 设置的60s的前端缓存失效其实没有起作用, 因为读取字典对象时只是判断了是否初始化,并没有判断是否过期

总体优化思路:

  1. 使用localstorage存储字典缓存, 避免webStorageCache的一个潜在问题
  2. 在推出登录时调用wsCache.delete清理字典缓存
  3. 在字典缓存读取时检查是否过期(通过wsCache.get方法?)
  4. 建议过期时间可以配置,1min时间有点太短了, 20min默认?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @beanww

        Issue actions

          前端字典缓存问题及优化建议 · Issue #145 · yudaocode/yudao-ui-admin-vue3