fix cache clear with regex and tests

This commit is contained in:
ilvalle
2014-12-16 20:32:51 +01:00
parent 5ea654ed06
commit d93810697f
2 changed files with 12 additions and 6 deletions
+4 -2
View File
@@ -128,10 +128,10 @@ class CacheAbstract(object):
Auxiliary function called by `clear` to search and clear cache entries
"""
r = re.compile(regex)
for key in storage:
for key in storage.keys():
if r.match(str(key)):
del storage[key]
break
return
class CacheInRam(CacheAbstract):
@@ -321,6 +321,8 @@ class CacheOnDisk(CacheAbstract):
for filename in filenames:
yield filename
def keys(self):
return [filename for dirpath, dirnames, filenames in os.walk(self.folder) for filename in filenames]
def get(self, key, default=None):
try: