Implement fact cache flushing alongside a command-line argument to invoke it.

This commit is contained in:
Josh Drake 2014-07-03 14:02:26 -05:00 committed by Michael DeHaan
commit 917e868f65
7 changed files with 32 additions and 7 deletions

View file

@ -47,13 +47,13 @@ class CacheModule(MemoryCacheModule):
def set(self, *args, **kwargs):
super(CacheModule, self).set(*args, **kwargs)
self.flush()
self.fsync()
def delete(self, *args, **kwargs):
super(CacheModule, self).delete(*args, **kwargs)
self.flush()
self.fsync()
def flush(self):
def fsync(self):
temp = tempfile.TemporaryFile('r+b')
try:
@ -63,3 +63,7 @@ class CacheModule(MemoryCacheModule):
shutil.copyfileobj(temp, f)
finally:
temp.close()
def flush(self):
super(CacheModule, self).flush()
self.fsync()