mirror of
https://github.com/ThomasGsp/HyperProxmox.git
synced 2025-03-09 15:40:18 +00:00
Improve cache system
This commit is contained in:
parent
b2dc3a4433
commit
4c9364c073
1 changed files with 18 additions and 6 deletions
|
@ -106,7 +106,7 @@ class Core:
|
||||||
hash_object = hashlib.md5("{0}-{1}-{2}-{3}-{4}".format(dest, date, cluster, node, vmid).encode('utf-8'))
|
hash_object = hashlib.md5("{0}-{1}-{2}-{3}-{4}".format(dest, date, cluster, node, vmid).encode('utf-8'))
|
||||||
hash_hex = hash_object.hexdigest()
|
hash_hex = hash_object.hexdigest()
|
||||||
|
|
||||||
cache = None # self.redis_cache.get_message(hash_hex)["value"]
|
cache = self.redis_cache.get_message(hash_hex)
|
||||||
|
|
||||||
if cache is None or self.generalconf["logger"]["debug"] == True:
|
if cache is None or self.generalconf["logger"]["debug"] == True:
|
||||||
if dest == "instances":
|
if dest == "instances":
|
||||||
|
@ -125,8 +125,8 @@ class Core:
|
||||||
self.redis_cache.insert_message(hash_hex, resultmbrequest, 3600)
|
self.redis_cache.insert_message(hash_hex, resultmbrequest, 3600)
|
||||||
return resultmbrequest
|
return resultmbrequest
|
||||||
else:
|
else:
|
||||||
print("Cache")
|
|
||||||
return cache
|
return json.loads(cache.replace("'", "\"").replace("None", "\"\""))
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -407,9 +407,21 @@ class Core:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get_clusters_conf(self, cluster=None):
|
def get_clusters_conf(self, cluster=None):
|
||||||
""" Find cluster informations from node """
|
|
||||||
|
""" Test Redis Cache """
|
||||||
|
hash_object = hashlib.md5("{0}-{1}".format("administration", cluster).encode('utf-8'))
|
||||||
|
hash_hex = hash_object.hexdigest()
|
||||||
|
|
||||||
|
cache = self.redis_cache.get_message(hash_hex)
|
||||||
|
|
||||||
|
if cache is None or self.generalconf["logger"]["debug"] == True:
|
||||||
clusters_informations = self.mongo.get_clusters_conf(cluster)
|
clusters_informations = self.mongo.get_clusters_conf(cluster)
|
||||||
|
self.redis_cache.insert_message(hash_hex, clusters_informations, 500)
|
||||||
return clusters_informations
|
return clusters_informations
|
||||||
|
else:
|
||||||
|
print("cache admin")
|
||||||
|
return json.loads(cache.replace("'", "\""))
|
||||||
|
|
||||||
|
|
||||||
def insert_clusters_conf(self, data):
|
def insert_clusters_conf(self, data):
|
||||||
testdata = valid_clusters_data(data)
|
testdata = valid_clusters_data(data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue