repoze / repoze.lru

Tiny LRU cache
http://pypi.python.org/pypi/repoze.lru/
Other
103 stars 24 forks source link

LRUCache is not thread safe #6

Closed snordhausen closed 12 years ago

snordhausen commented 12 years ago

When the clear() method is called on a LRUCache, concurrently running get() and put() calls may throw exceptions.

The get() method may throw an exception because it tries to self.clock[pos]['ref'] = True but the clear() method is only slowly rebuilding the self.clock list. This results in index out of bounds.

put() may except when it is searching for a place to put an item. put() walks along self.clock and can experience index out of bounds just like the get() method.