diff -r fb4b68592b7c -r 7e7002215f9e E5Utilities/E5Cache.py --- a/E5Utilities/E5Cache.py Sat Oct 14 20:08:47 2017 +0200 +++ b/E5Utilities/E5Cache.py Sun Oct 15 17:21:20 2017 +0200 @@ -10,6 +10,7 @@ from __future__ import unicode_literals +# TODO: add timeout for cached entries class E5Cache(object): """ Class implementing a LRU cache of a specific size. @@ -50,13 +51,14 @@ """ Private method to adjust the cache to its size. """ - while len(self.__keyList) > self.__size: - key = self.__keyList.pop(0) + removeList, self.__keyList = \ + self.__keyList[:-self.__size], self.__keyList[-self.__size:] + for key in removeList: del self.__store[key] def getSize(self): """ - Public method to get the size of the cache. + Public method to get the maximum size of the cache. @return maximum number of entries of the cache @rtype int @@ -65,7 +67,7 @@ def setSize(self, newSize): """ - Public method to change the size of the cache. + Public method to change the maximum size of the cache. @param newSize maximum number of entries that may be stored in the cache