Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cache data #16

Merged
merged 15 commits into from
Aug 29, 2024
Merged

feat: cache data #16

merged 15 commits into from
Aug 29, 2024

Conversation

wyq777x
Copy link
Collaborator

@wyq777x wyq777x commented Aug 12, 2024

cache
data type:

 std::unordered_map<std::string,CacheEntry>

Expectation

  • generateCacheKey 生成缓存键(Function函数)
  • cacheCheck 检查缓存存在性 (non-function非函数,already embed into request已经嵌入request中了)
  • cacheUpdate 更新缓存 (同上)
  • cacheExpire 缓存过期机制(Function bool isCacheExpired and corresponding adaptation)
  • cacheExceptionHandle 缓存异常处理
  • cacheLimit 缓存限制64MB(LRU style)
  • 图片缓存

After that

  • 缓存失效机制

@wyq777x wyq777x added the feature New feature or request label Aug 12, 2024
@wyq777x wyq777x self-assigned this Aug 12, 2024
github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
@Serein207 Serein207 linked an issue Aug 12, 2024 that may be closed by this pull request
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.h Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.h Outdated Show resolved Hide resolved
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.h Outdated Show resolved Hide resolved
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.h Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.h Outdated Show resolved Hide resolved
@Serein207
Copy link
Member

Serein207 commented Aug 24, 2024

  • 新增清空所有缓存的函数
  • NetworkClient 所有合适的接口函数添加默认参数 bool cache = false ,如果不启用缓存则在网络请求后更新缓存,如果启用缓存则优先尝试查询缓存

@Serein207
Copy link
Member

把和cache有关的封装成独立的类,不要全都塞在 NetworkClient里

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/Infrastructure/Network/HttpsAccessManager.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/HttpsAccessManager.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/HttpsAccessManager.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.h Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.h Outdated Show resolved Hide resolved
…quest<api::Evento> and request<api::Github> in 'NetworkClient.h'
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/Infrastructure/Network/HttpsAccessManager.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/HttpsAccessManager.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/HttpsAccessManager.cc Outdated Show resolved Hide resolved
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/Infrastructure/Network/NetworkClient.h Outdated Show resolved Hide resolved
@Serein207 Serein207 marked this pull request as ready for review August 29, 2024 09:40
Copy link

clang-tidy review says "All clean, LGTM! 👍"

@Serein207 Serein207 changed the title feat: data-caching functionality feat: cache data Aug 29, 2024
@Serein207 Serein207 merged commit e3158e9 into dev Aug 29, 2024
5 checks passed
@Serein207 Serein207 deleted the feat/net/cache branch August 29, 2024 10:06
zwow-cj pushed a commit that referenced this pull request Aug 30, 2024
* create cache and aux function generateCacheKey in class NetworkClient

* create cache and aux function generateCacheKey in class NetworkClient

* feat: add cacheKey generating,cache Checking and cache Updating to request<api::Evento> and request<api::Github> in 'NetworkClient.h'

* feat: add struct CacheEntry ,bool isCacheEntryExpired and cacheExpireing functionality(TTL=3 hours) into existing codes in 'NetworkClient.h'

* feat: modify data struct of cache and add LRU cacheLimit up to 64MB and aux function updateCache in 'NetworkClient.h'

* feat: cache exceptions handler

* feat: photos cache in HttpAccessManager,providing aux functionssaveToFile,generateFilename

* fix: merge from branch dev and fix the type matching problem

* perf: improve performance and fix potential problems

* refactor: cache manager

* feat: download file

* feat: get cache size

* feat: support request cache

* feat: use ttl

---------

Co-authored-by: Serein <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: cache data
2 participants