Skip to content

Conversation

@erase2004
Copy link
Contributor

@erase2004 erase2004 commented Apr 17, 2025

Notable Changes

  • 允許文章可依照 request 的內容,產生不同的 cache。

Notes

  • 目前僅有會員文章有權限設定,需要依照使用者的權限,來決定回傳的內容,因此,在產生 cache key 時,需要把使用者權限納入計算的範圍。
  • 跟會員文章閱讀有關的權限,從 WAS 的程式碼中,可以歸納出以下三類:
    • 'read:member-posts:all' - 第一類:全部會員文章
    • 'read:member-posts:[post_id_1, ...]' - 第二類:部份會員文章
    • '' - 第三類:無會員文章
  • 針對這三類,產生並使用各自的 cache。
  • 目前的修改僅提供一個與 cache 整合的方向,尚有以下問題待解決:
    • 第二類由於內容變化性較大,會導致 cache 效率下降,例如:使用者 A 有 1,2,3,使用者 B 有 1,2,5,雖然有共通的 1,2,但在計算時,會把各自的所有的 list 納入計算,導致 A 與 B 的 cache key 不同,因此無法共用
    • 除了會員文章之外,一般文章、大小類別等,都會分成三類來 cache,這部份其實也會降低 cache 效率,需要再改善
    • cache 在失效前,回傳都會是 cache 的內容
  • 參考資訊

@nickchen111
Copy link
Contributor

cache 在失效前,回傳都會是 cache 的內容
想確認一下這個問題是指cache 跟 資料庫 一致性的問題嗎?

@erase2004
Copy link
Contributor Author

cache 在失效前,回傳都會是 cache 的內容 想確認一下這個問題是指cache 跟 資料庫 一致性的問題嗎?

對,目前寫入後不會更新或清除 cache,會導致有一段時間,cache 和資料庫的資料不一致

Copy link
Contributor

@nickchen111 nickchen111 left a comment

Choose a reason for hiding this comment

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

LGTM!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants