Fixed decorator order, now caching works

This commit is contained in:
Shay Nehmad 2019-09-29 17:14:28 +03:00
parent 1060c004bd
commit 93c9aaa513
1 changed files with 3 additions and 3 deletions

View File

@ -88,17 +88,17 @@ class Monkey(Document):
return os return os
# TODO This is not a field therefore cache shouldn't be here # TODO This is not a field therefore cache shouldn't be here
@ring.lru()
@staticmethod @staticmethod
@ring.lru(coder=ring.coder.JsonCoder())
def get_label_by_id(object_id): def get_label_by_id(object_id):
print("Actually in get_label_by_id - not cached for {}".format(str(object_id))) print("Actually in get_label_by_id - not cached for {}".format(str(object_id)))
current_monkey = Monkey.get_single_monkey_by_id(object_id) current_monkey = Monkey.get_single_monkey_by_id(object_id)
return Monkey.get_hostname_by_id(object_id) + " : " + current_monkey.ip_addresses[0] return Monkey.get_hostname_by_id(object_id) + " : " + current_monkey.ip_addresses[0]
@ring.lru()
@staticmethod @staticmethod
@ring.lru(coder=ring.coder.JsonCoder())
def get_hostname_by_id(object_id): def get_hostname_by_id(object_id):
print("Actually in get_hostname_by_id - not cached for {}".format(str(object_id)))
return Monkey.get_single_monkey_by_id(object_id).hostname return Monkey.get_single_monkey_by_id(object_id).hostname
def set_hostname(self, hostname): def set_hostname(self, hostname):