Go back to humble cachetools.func

This commit is contained in:
2021-03-07 20:22:14 +01:00
parent 8d78368db3
commit e73f176d10
3 changed files with 20 additions and 2 deletions
+14 -1
View File
@@ -25,10 +25,11 @@ from flask_cors import CORS
cache = Cache()
logging.basicConfig(
filename='agora.log',
level=logging.WARNING,
level=logging.DEBUG,
format='%(asctime)s %(levelname)s %(name)s %(threadName)s : %(message)s'
)
# what is this doing here, I have no idea.
# todo: move to util.
def wikilink_to_url(label, base, end):
@@ -89,4 +90,16 @@ def create_app(test_config=None):
output = s
return output
@app.before_request
def log_entry():
app.logger.debug('Initiating request handling.')
@app.after_request
def log_exit(req):
app.logger.debug(f'Finished handling {req}.')
return req
return app
+2
View File
@@ -160,6 +160,7 @@ def jump():
@bp.route('/node/<node>')
@bp.route('/node/<node>/uprank/<user_list>')
def node(node,user_list=[]):
# current_app.logger.debug(f'Assembling node {node}.')
if user_list:
rank = user_list.split(",")
else:
@@ -175,6 +176,7 @@ def node(node,user_list=[]):
search_subnodes = db.search_subnodes(node)
# current_app.logger.debug(f'Assembled node {node}.')
return render_template(
# yuck
'content.html',
+4 -1
View File
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import cachetools.func
import glob
import itertools
import re
@@ -80,7 +81,8 @@ class Graph:
nodes = [node for node in G.nodes() if node.wikilink in permutations and node.subnodes]
return nodes
@cache.memoize(timeout=30)
# @cache.memoize(timeout=30)
@cachetools.func.ttl_cache(ttl=20)
def nodes(self, include_journals=True):
current_app.logger.debug('Loading graph.')
# returns a list of all nodes
@@ -122,6 +124,7 @@ class Graph:
# does this belong here?
# @cache.memoize(timeout=30)
@cachetools.func.ttl_cache(ttl=30)
def subnodes(self, sort=lambda x: x.uri.lower()):
# Markdown.
subnodes = [Subnode(f) for f in glob.glob(os.path.join(config.AGORA_PATH, '**/*.md'), recursive=True)]