24 lines
503 B
Python
24 lines
503 B
Python
import time
|
|
|
|
|
|
def cache(func):
|
|
cache_dict = {}
|
|
|
|
def wrapper(*mamamia, **kwmamamia):
|
|
if mamamia in cache_dict:
|
|
print("Ergebnis aus dem Cache geladen!")
|
|
return cache_dict[mamamia]
|
|
else:
|
|
print("Ergebnis wird berechnet ...")
|
|
result = func(*mamamia, **kwmamamia)
|
|
cache_dict[mamamia] = result
|
|
return result
|
|
return wrapper
|
|
|
|
|
|
@cache
|
|
def gehalt(name):
|
|
# Komplexe Berechnung
|
|
time.sleep(3)
|
|
return 3000
|