Page MenuHomeSoftware Heritage

common/utils: Add a django_cache decorator and use it in codebase
ClosedPublic

Authored by anlambert on Apr 7 2022, 5:18 PM.

Details

Summary

Add a decorator enabling to put the result of a function call in Django
cache, subsequent calls will then directly return the cached value.

Use that decorator whenever it is possible in swh-web codebase to simplify
the handling of cached values and improve code readability.

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D7526 (id=27304)

Rebasing onto 96b27bf43e...

Current branch diff-target is up to date.
Changes applied before test
commit b364c93d81a6286c238336aa102b7ba2a55b5d66
Author: Antoine Lambert <anlambert@softwareheritage.org>
Date:   Thu Apr 7 16:59:06 2022 +0200

    common/utils: Add a django_cache decorator and use it in codebase
    
    Add a decorator enabling to put the result of a function call in Django
    cache, subsequent calls will then directly return the cached value.
    
    Use that decorator whenever it is possible in swh-web codebase to simplify
    the handling of cached values and improve code readability.

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1696/ for more details.

This revision is now accepted and ready to land.Apr 8 2022, 11:13 AM