[FEAT/#112] 이미지 캐시를 구현하고, 비동기 이미지 설정 메소드에 적용합니다. #113
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🤔 배경
스티커 이모지를 네트워킹을 통해 비동기로 불러오는데, 네트워크 환경에 따라 불러오는 속도가 느려 사용자 경험이 좋지 않았습니다.
📃 작업 내역
NSCache를 활용해 메모리 캐시를 구현합니다.
FileManager를 통해 Image를 Data로 변환해 저장합니다.
캐싱 방식
2-1. 먼저 메모리 캐시에서 찾고, 없으면 디스크 캐시에서 찾아 메모리 캐시를 업데이트한 후 이미지를 리턴합니다.
2-2. 캐시 히트에 실패한 경우, 네트워크 요청을 통해 이미지를 가져오고 메모리 캐시와 디스크 캐시를 업데이트하고 이미지를 설정합니다.
✅ 리뷰 노트
빠르게 구현한거라 가독성이 좋지 않습니다🥲