在Java中创建新的JSON对象与使用Redis中的JSON对象相比。

huangapple 未分类评论45阅读模式
英文:

Creating new Json object in java vs using JSON object from redis

问题

以下是翻译好的内容:

在HttpServletRequest对象中有一些未更改的数据(例如用户的资产详细信息)。我想将这些值设置为API响应。哪种方法是最佳的?如何操作?

  1. 从HttpServletRequest获取数据并构建用于响应的JSON对象。
  2. 将JSON响应存储在Redis中,并在API响应中使用这些JSONObject。
英文:

Few unchanged data (for ex. asset details of a user) available in HttpServletRequest object. I want to set these value to a API response. Which one is the best way? How?

  1. Getting data from HttpServletRequest and construct JSON object for Response
  2. Store JSON response in Redis and use these JSONObject for API Response

答案1

得分: 0

因为这被标记为[tag:performance]... 选项1会更快,因为它不涉及任何外部调用。

然而,无论Redis有多快,直接从HttpServletRequest读取总是更快的。

英文:

Since this is tagged [tag:performance]... option 1 will be faster since it doesn't involve any external calls.

However fast Redis might be, reading from HttpServletRequest directly will always be faster.

huangapple
  • 本文由 发表于 2020年4月6日 21:06:39
  • 转载请务必保留本文链接:https://java.coder-hub.com/61060551.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定