Exemplo n.º 1
0
 def __init__(self):
     # checkPathes
     utils._mkdir(config.CACHEDIR)
     
     # load index-Hashtable
     if os.path.isfile(self.indexFilename):
         self.loadIndex()
Exemplo n.º 2
0
 def save(self, obj, module, id, starttime = None, endtime = None):
     print "save obj for (%s, %s)" %(module, id)
     if starttime==None or endtime==None:
         filename=self.hash(str(id))
     else:
         filename=self.hash(str(id)+str(starttime)+str(endtime))
     
     #create dirs if not exist
     dir=os.path.join(config.CACHEDIR, module)
     utils._mkdir(dir)
     
     # store data
     f=open(os.path.join(dir, filename), "w")
     cPickle.dump(obj, f)
     f.close()
     
     # add to index
     if starttime==None or endtime==None:
         self.index[module][str(id)]=filename
     else:
         self.index[module][str(id)][(starttime, endtime)]=filename
     self.saveIndex()