Skip to content
Snippets Groups Projects
Commit 77851f1d authored by inso's avatar inso
Browse files

Fixed person caching

parent 8eb586da
Branches
Tags
No related merge requests found
...@@ -387,29 +387,29 @@ class Person(object): ...@@ -387,29 +387,29 @@ class Person(object):
:return: True if a changed was made by the reload. :return: True if a changed was made by the reload.
''' '''
self._cache_mutex.lock() self._cache_mutex.lock()
change = False
try: try:
if community.currency not in self._cache: if community.currency not in self._cache:
self._cache[community.currency] = {} self._cache[community.currency] = {}
change = False try:
before = self._cache[community.currency][func.__name__] before = self._cache[community.currency][func.__name__]
except KeyError:
change = True
try:
value = func(self, community) value = func(self, community)
if not change: if not change:
if type(value) is dict: if type(value) is dict:
hash_before = (hash(tuple(frozenset(sorted(before.keys())))), hash_before = (str(tuple(frozenset(sorted(before.keys())))),
hash(tuple(frozenset(sorted(before.items()))))) str(tuple(frozenset(sorted(before.items())))))
hash_after = (hash(tuple(frozenset(sorted(value.keys())))), hash_after = (str(tuple(frozenset(sorted(value.keys())))),
hash(tuple(frozenset(sorted(value.items()))))) str(tuple(frozenset(sorted(value.items())))))
change = hash_before != hash_after change = hash_before != hash_after
elif type(value) is bool: elif type(value) is bool:
change = before != value change = before != value
self._cache[community.currency][func.__name__] = value self._cache[community.currency][func.__name__] = value
except KeyError:
change = True
except Error: except Error:
return False return False
finally: finally:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment