def schematic(self): ## Use cache if possible temp = self.schematics #if temp==None or 1==1: if temp == None: # print(self.name+'_schematics no cache') try: temp = generate_schematic(self) self.schematics = pickle.dumps(temp) self.save() except: print('schematics failed for ', self.name) else: # print(self.name+'_schematics used cache') try: temp = pickle.loads(temp) except: temp = generate_schematic(self) self.schematics = pickle.dumps(temp) self.save() return temp
def schematic(self): ## Use cache if possible temp = self.schematics #if temp==None or 1==1: if temp==None: # print(self.name+'_schematics no cache') try: temp = generate_schematic(self) self.schematics = pickle.dumps(temp) self.save() except: print('schematics failed for ',self.name) else: # print(self.name+'_schematics used cache') temp = pickle.loads(temp) return temp
def schematic(self): ## Use cache if possible temp = cache.get(self.name+'_schematics') if temp==None: print(self.name+'_schematics no cache') try: temp = cache.set(self.name+'_schematics', generate_schematic(self), 60*60*24*2) #two days temp = cache.get(self.name+'_schematics') except: temp = {} else: print(self.name+'_schematics used cache') # temp = cache.set(self.name+'_schematics', generate_schematic(self), 60*60*24*2) #two days # temp = generate_schematic(self) #override return temp
def schematic(self): ## Use cache if possible temp = cache.get(self.name + '_schematics') if temp == None: print(self.name + '_schematics no cache') try: temp = cache.set(self.name + '_schematics', generate_schematic(self), 60 * 60 * 24 * 2) #two days temp = cache.get(self.name + '_schematics') except: temp = {} else: print(self.name + '_schematics used cache') # temp = cache.set(self.name+'_schematics', generate_schematic(self), 60*60*24*2) #two days # temp = generate_schematic(self) #override return temp
def schematic(self): cache_key = self.name + "_all_schematics" try: temp = cache.get(cache_key) except: temp = None if temp == None: temp = generate_schematic(self) cache.set(cache_key, temp, 60 * 60 * 24 * 7) cache_key = self.name + "_cons_schematic" schematic = temp['schematic_2_c'] cache.set(cache_key, schematic, 60 * 60 * 24 * 7) cache_key = self.name + "_wt_schematic" schematic = temp['schematic_2_wt'] cache.set(cache_key, schematic, 60 * 60 * 24 * 7) cache_key = self.name + "_chem_summary" summary = temp['summary'] cache.set(cache_key, summary, 60 * 60 * 24 * 7) return temp