-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flush the TOML parsing cache for every incoming request
- Loading branch information
1 parent
fcfc383
commit 9e76add
Showing
4 changed files
with
22 additions
and
12 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from typing import TYPE_CHECKING, Callable | ||
|
||
from .db import clear_cache | ||
|
||
if TYPE_CHECKING: | ||
from django.http import HttpRequest, HttpResponse | ||
|
||
|
||
class TOMLCacheClearingMiddleware: | ||
def __init__(self, get_response: Callable[["HttpRequest"], "HttpResponse"]): | ||
self.get_response = get_response | ||
|
||
def __call__(self, request: "HttpRequest") -> "HttpResponse": | ||
# We flush the TOML parsing cache on each request | ||
clear_cache() | ||
|
||
return self.get_response(request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters