Skip to content

Draft: Extract session functions of region management in transaction

KoeMai requested to merge 1769_extractRegionManagementFromSession into master

What does this MR do?

The Session class is a very large class with different responsibilities. This MR extracts the region management from Session into a new transaction class UserRegionTransactions.

The UserRegionTransaction requires a cache (session, mem), so that not every permission check executes a "slow" DB communication on check of a region or working group membership. Currently, the session is used.

This MR move the cache from Session into a session independent redis mem cache.

image

Why moving the cache from session to redis?

The cache inside the session, makes it simple if information are used during a single session from one user. It is a simple storage, in the backend we use Redis as session cache. The biggest problem is that a session cache is independent of other users chances in the platform.

If working group responsible user removes the permission for a group, then the session will not know it, without checking the DB. A session independent cache (like the class Mem redis wrapper) for the relation between region/working group and the user allows

  • Use the cached value until a modification of the relations is done (use cache longer then session life-time) -> Login is quicker
  • Revoke relations by other users
  • Modification of the redis structure for userRegions is only related to UserRegions-Transactions not to the complete session management/other modules. It is encapsulated.

Development Responsibilies

  • Changes on fs_foodsaver_has_bezirk should be done only via UserRegionsTransactions.
  • Delete cached content on modification, so that a load on next get() is possible

How confident are you it won't break things if deployed?

I hope not.

Links to related issues

How to test

Screenshots (if applicable)

Checklist

  • added a test, or explain why one is not needed/possible...
  • no unrelated changes
  • asked someone for a code review
  • set a "for:" label to indicate who will be affected by this change
  • added to the next milestone (see https://gitlab.com/foodsharing-dev/foodsharing/-/milestones, unless it has a "for:Dev" label)
  • added an entry to CHANGELOG.md
  • added a short text in the release notes to /release-notes/YYYY-MM.md
  • Once your MR has been merged, you are responsible to create a testing issue in the Beta Testing forum: https://foodsharing.de/region?bid=734&sub=forum. Please change the MRs label to "state:Beta testing".
    • Consider writing a detailed description in German.
    • Describe in a few sentences, what should be tested from a user perspective.
    • Also mention different settings (e.g. different browsers, roles, ...) how this change can be tested.
    • Be aware, that also non technical people should understand.
Edited by KoeMai

Merge request reports