client-barcode: Add an item cache
This commit is contained in:
parent
5b42351454
commit
61af03c5f9
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue