from mailbox_state import MailboxState
CACHE_FILENAME = "message_cache.dat"
+CACHE_VERSION = 1
class CachingData:
"""This class is responsible for the caching of data."""
try:
cachefile = open(CACHE_FILENAME, 'rb')
self.version, self.data = pickle.load(cachefile)
+ if(self.version != CACHE_VERSION):
+ logging.warning("Cache file has version %s and the script version is %s.",
+ self.version, self.data)
+ raise IOError
logging.info("Cache version %s", self.version)
logging.debug("%s users found.", len(self.data))
except IOError:
- self.version = 0
+ self.version = CACHE_VERSION
self.data = {}
with open(CACHE_FILENAME, 'wb') as cachefile:
pickle.dump((0, self.data), cachefile)
return
# serialize in file
- self.version += 1
pickle.dump((self.version, self.data), cachefile)
logging.debug("%s users stored.", len(self.data))
cachefile.close()