From e88cdbfe93085ffb0f81e270303df47a47fb68c6 Mon Sep 17 00:00:00 2001
From: Markus Scheidgen <markus.scheidgen@gmail.com>
Date: Mon, 2 Sep 2019 14:08:08 +0200
Subject: [PATCH] Cache user objects.

---
 nomad/datamodel/base.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/nomad/datamodel/base.py b/nomad/datamodel/base.py
index 9c76f6ca8b..d8a81fd796 100644
--- a/nomad/datamodel/base.py
+++ b/nomad/datamodel/base.py
@@ -15,6 +15,7 @@
 from typing import Iterable, List, Dict, Type, Tuple, Callable, Any
 import datetime
 from elasticsearch_dsl import Keyword
+from cachetools import cached, TTLCache
 
 from nomad import utils, config, infrastructure
 
@@ -56,6 +57,7 @@ class User:
         self.repo_user_id = repo_user_id
 
     @staticmethod
+    @cached(cache=TTLCache(maxsize=2048, ttl=24 * 3600))
     def get(*args, **kwargs) -> 'User':
         return infrastructure.keycloak.get_user(*args, **kwargs)  # type: ignore
 
-- 
GitLab