rename caching functions on server
This commit is contained in:
parent
0561aa54f4
commit
d5429f0c2b
@ -27,17 +27,17 @@ from django.http import Http404
|
||||
from .models import Coin
|
||||
|
||||
|
||||
def get_last_modified_index(request):
|
||||
return cache.get(f'last_modified_index', set_last_modified_index())
|
||||
def get_last_modified_coin(request):
|
||||
return cache.get('last_modified_coin', set_last_modified_coin())
|
||||
|
||||
|
||||
def set_last_modified_index():
|
||||
def set_last_modified_coin():
|
||||
''' set and return the datetime of the last coin added '''
|
||||
try:
|
||||
last_modified = Coin.objects.latest('date_modified').date_modified
|
||||
except Coin.DoesNotExist:
|
||||
raise Http404(f'Das Land "{name_iso}" existiert nicht')
|
||||
cache.set(f'last_modified_index', last_modified)
|
||||
cache.set('last_modified_coin', last_modified)
|
||||
return last_modified
|
||||
|
||||
|
||||
|
@ -27,13 +27,13 @@ from django.template import loader
|
||||
from django.template.defaultfilters import register
|
||||
from django.views.decorators.http import condition
|
||||
|
||||
from .cache import (get_last_modified_index, set_last_modified_index,
|
||||
from .cache import (get_last_modified_coin, set_last_modified_coin,
|
||||
get_last_modified_country, set_last_modified_country)
|
||||
from .models import Country, Stamp, Coin, User
|
||||
from .helper import total_coin_sum, coin_sum_of_
|
||||
|
||||
|
||||
@condition(last_modified_func=get_last_modified_index)
|
||||
@condition(last_modified_func=get_last_modified_coin)
|
||||
def index(request):
|
||||
''' index view '''
|
||||
|
||||
@ -378,7 +378,7 @@ def add_coin(request):
|
||||
in_collector = ec,
|
||||
exists = exists)
|
||||
|
||||
set_last_modified_index()
|
||||
set_last_modified_coin()
|
||||
set_last_modified_country(country.name_iso)
|
||||
return response()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user