检索规则说明:AND代表“并且”;OR代表“或者”;NOT代表“不包含”;(注意必须大写,运算符两边需空一格)
检 索 范 例 :范例一: (K=图书馆学 OR K=情报学) AND A=范并思 范例二:J=计算机应用与软件 AND (U=C++ OR U=Basic) NOT M=Visual
作 者:白晓涛 陶智勇[1] BAI Xiaotao;TAO Zhiyong(Wuhan Rearch Institude of Posts and Telecommunications,Wuhan 430074,China)
出 处:《网络新媒体技术》2020年第5期35-38,共4页Network New Media Technology
基 金:湖北农村地区宽带建设及信息服务发展策略研究项目编号:D20143005。
摘 要:在Java Web开发中,当用户经过权限验证后,用户信息一般保存到Redis,Ehcache等缓存中。但后台逻辑代码在获取用户信息时还需要从缓存中获取,并进行格式转换,这样速度很慢,且代码复杂冗余。为了优化业务代码在获取用户信息时的效率问题和操作冗余问题,本文总结并完善了当前开发中最高效的两种缓存用户信息的方式,HttpServletRequest和ThreadLocal。这两种方式直接将用户信息以对象方法保存到内存中,获取快速且不需要类型转换,比缓存方式效率更高。本文深入探索了这两种方式的实现原理和底层结构,并从时间复杂度,实现难度,编程思想,扩展性等方面进行了详细比较。In Java Web development,user information is usually saved to Redis,Ehcache and other caches when the user has been authorized.So the background program needs to get user information from the cache and convert the type.This is slow,and the code is complex and redundant.In order to optimize the efficiency and redundancy of business code in obtaining user information,the paper summarizes and improves two most efficient ways of caching user information in current development,and they are HttpServletRequest and ThreadLocal.These two methods directly store user information in memory,and obtain it quickly without type conversion,which are more efficient than caching method.This paper studies the principle and the underlying structure of two methods.And the two methods are compared from the aspects of time complexity,implementation difficulty,programming idea,scalability,etc.
关 键 词:缓存 用户信息 HttpServletRequest ThreadLocal
分 类 号:TP312.2[自动化与计算机技术—计算机软件与理论]
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在链接到云南高校图书馆文献保障联盟下载...
云南高校图书馆联盟文献共享服务平台 版权所有©
您的IP:3.141.43.16