From 61af03c5f9900db1ab5916a3802d5eb59f0f79d7 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Wed, 5 Oct 2011 12:39:22 +0200 Subject: [PATCH] client-barcode: Add an item cache --- client-barcode/freitagskasse.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client-barcode/freitagskasse.py b/client-barcode/freitagskasse.py index 48330b8..14deba5 100644 --- a/client-barcode/freitagskasse.py +++ b/client-barcode/freitagskasse.py @@ -56,6 +56,7 @@ def error_page(message): class Status: def __init__(self): self._reset() + self.item_cache = dict() def _reset(self): self.auth_blob = None @@ -122,7 +123,12 @@ class Status: self._reset() def find(self, item_id): - return net.get_item(item_id) + try: + return self.item_cache[item_id] + except KeyError: + item = net.get_item(item_id) + self.item_cache[item_id] = item + return item def buy(self, item): assert(self.logged_in())