dknig1b commented on a change in pull request #41: Memoize loader.load and 
loader.load_json
URL: https://github.com/apache/aurora/pull/41#discussion_r222119497
 
 

 ##########
 File path: src/main/python/apache/aurora/config/loader.py
 ##########
 @@ -56,17 +62,49 @@ def flush_schemas(cls):
     cls.register_schema(base_schema)
 
   @classmethod
-  def load(cls, loadable):
-    return cls.load_raw(loadable).environment
+  def gen_content_key(cls, loadable):
+    key = None
+    if isinstance(loadable, Compatibility.stringy) and 
os.path.isfile(loadable):
+      with open(loadable) as fp:
+        key = hashlib.md5(fp.read()).hexdigest()
+    elif hasattr(loadable, 'read') and callable(loadable.read):
+      key = hashlib.md5(loadable.read()).hexdigest()
+      loadable.seek(0)
+    return key
 
 Review comment:
   We could use the loadable as the key (that was the previous implementation) 
however someone could change the loadable's content and the cache would not be 
updated.
   
   I used the ConfigExecutors.matches instead of duplicating the logic.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to