From d93cf586a1d09773e4e74956ed21a8d59a6cb249 Mon Sep 17 00:00:00 2001 From: nathaniel smith Date: Sat, 1 Aug 2015 16:27:08 -0700 Subject: [PATCH] use lru cache for data --- tildetown-py/cgi.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tildetown-py/cgi.py b/tildetown-py/cgi.py index 021a81e..d452082 100644 --- a/tildetown-py/cgi.py +++ b/tildetown-py/cgi.py @@ -1,3 +1,4 @@ +from functools import lru_cache import json import os import random @@ -22,11 +23,9 @@ SITE_NAME = 'tilde.town' app = Flask('~cgi') -_site_context = None +@lru_cache(maxsize=32) def site_context(): - if not _site_context: - _site_context = get_data() - return _site_context + return get_data() def slurp(file_path): contents = None