use lru cache for data
parent
58137b95c2
commit
d93cf586a1
|
@ -1,3 +1,4 @@
|
||||||
|
from functools import lru_cache
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
|
@ -22,11 +23,9 @@ SITE_NAME = 'tilde.town'
|
||||||
|
|
||||||
app = Flask('~cgi')
|
app = Flask('~cgi')
|
||||||
|
|
||||||
_site_context = None
|
@lru_cache(maxsize=32)
|
||||||
def site_context():
|
def site_context():
|
||||||
if not _site_context:
|
return get_data()
|
||||||
_site_context = get_data()
|
|
||||||
return _site_context
|
|
||||||
|
|
||||||
def slurp(file_path):
|
def slurp(file_path):
|
||||||
contents = None
|
contents = None
|
||||||
|
|
Reference in New Issue