-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task(api): otimiza piores e médios casos da atualização do db por mei…
…o de redis cache, pages fingerprints e multithreading (#183) * devops(python): django-redis lib and to container * core(settings): config redis cache with env vars * utils(scraper): add web page fingerprinter * utils(commands): separate mult replace into func * api(commands): add cache verification to update db * utils(commands): move mult replace from file * utils(tests): check cache access of finge * api(commands): add multithreading to db update * typo(commands): change 'bando' to 'banco' * core(settings): set up global time constants * api(decorators): wrapper to del cache keys * api(commands): move cache set to take effect * api(models): add cache handle to unique delete * api(tests): add check to models delete
- Loading branch information
Showing
13 changed files
with
351 additions
and
68 deletions.
There are no files selected for viewing
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,21 @@ | ||
from django.core.cache import cache | ||
from api.models import cache_error_msg | ||
import functools | ||
|
||
|
||
def handle_cache_before_delete(query_func: callable) -> callable: | ||
|
||
@functools.wraps(query_func) | ||
def wrapper(*args, **kwargs): | ||
queryset = query_func(*args, **kwargs) | ||
|
||
try: | ||
for query in queryset: | ||
cache_key = query.get_cache_key() | ||
cache.delete(cache_key) | ||
except: # pragma: no cover | ||
raise ValueError(cache_error_msg) | ||
else: | ||
queryset.delete() | ||
|
||
return wrapper |
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
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
Oops, something went wrong.