Consider caching more at the service layer
- Dominant language
- Clojure
- Stars
- 66
- Forks
- 28
- Avg merge
- 7d 4h
- Merged PRs (30d)
- 2
Description
While implementing #2646 we noticed that perhaps we should cache the workflows so that we are not fetching them for every request from the database.
We originally had only the db and api layers and the middleware often goes directly to the db level code e.g. `with-context` that populates the `context/*roles*` that needs to fetch various parts of the database.
Also implementing #2728 there was a performance problem because deleting one application leads to invalidation of the entire application cache. We resorted to updating the cache once all deletion has been done (making a non-cache updating delete in the PR).
We could
- consider adding more comprehensive caching to the service layer
- have explicit cache invalidation capability in the service layer, and reset the cache when modifying
- cache the `get-xxx` and `get-all-xxxs` types of functions that are heavy to fetch, transform etc.
- make middleware, and perhaps other parts of REMS to rather use the service layer than directly db layer
- caching `db` representation belongs to `db` layer but full "joined" representation to the `service`?
- updating one item should not cause an invalidation of the entire items cache
Contributor guide
Research direction
Start by reading the context/*roles* middleware path and the service and db layers, then review the related work in #2646 and #2728. The issue needs an agreed scope before implementation: identify which get/get-all operations to cache, define service-layer invalidation, and decide which middleware callers should stop using the db layer directly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- backend, performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100