Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Add redis caching to getting user notifications and projects [MOD-540] #723

Merged
merged 16 commits into from
Oct 12, 2023

Conversation

OmegaJak
Copy link
Contributor

@OmegaJak OmegaJak commented Oct 3, 2023

Specifically:

  • /user/{id|username}/notifications
  • /user/{id|username}/projects

both of these now cache their results in redis.

Cases I could think of that the user projects cache needs invalidation:

  • Team member joined (clear team member's cache)
  • Team member removed (clear team member's cache)
  • Project created (clear cache of creating user)
  • Project removed (clear cache of all team members)

Cases I could think of that the user notifications cache needs invalidation:

  • Notification added
  • Notification removed
  • Notification read

@OmegaJak
Copy link
Contributor Author

OmegaJak commented Oct 3, 2023

Draft because I haven't tested this much yet and still need to. I'm hoping to write automated tests around the invalidation conditions using #719

@OmegaJak OmegaJak mentioned this pull request Oct 9, 2023
@OmegaJak OmegaJak marked this pull request as ready for review October 11, 2023 21:59
tests/common/dummy_data.rs Outdated Show resolved Hide resolved
tests/common/environment.rs Outdated Show resolved Hide resolved
tests/common/dummy_data.rs Outdated Show resolved Hide resolved
@thesuzerain thesuzerain merged commit abf4cd7 into master Oct 12, 2023
8 of 10 checks passed
@thesuzerain thesuzerain deleted the add-some-redis-caching branch October 12, 2023 22:52
thesuzerain pushed a commit that referenced this pull request Dec 5, 2023
#723)

* Add redis caching to getting a user's project ids

* Run `cargo sqlx prepare` to update the sqlx-data.json

* Add redis caching for getting user notifications

* Fix new clippy warnings

* Remove log that shouldn't have been committed

* Batch insert of notifications (untested)

* sqlx prepare...

* Fix merge conflict things and use new redis struct

* Fix bug with calling delete_many without any elements (caught by tests)

* cargo sqlx prepare

* Add tests around cache invalidation (and fix bug they caught!)

* Some test reorg based on code review suggestions
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants