def _writeCompileCache(name, thing, serializeFunc): DEBUG(CACHE, "writing compile cache") path = _fixPath(Configuration.compileCacheRoot, name + "c") try: _writeDisk(path, serializeFunc(thing)) except: ERROR("error writing to compile cache: %s" % sys.exc_info()[1])
def clearCache(name, arguments, matchExact=None): if matchExact: path, svr, fk = _genCachedComponentPath(name, arguments) _expireCacheFile(path) else: name = _normpath(name) md5, fullKey = _genCacheKey(arguments) if Configuration.numServers: names = ' '.join([ _shellEscape("%s/%s/%s" % (Configuration.componentCacheRoot, i, name)) for i in range(Configuration.numServers) ]) else: names = "%s/%s" % (Configuration.componentCacheRoot, _shellEscape(name)) greps = [] if fullKey is None: raise RuntimeError, \ "key files not written, but attempt to use inexact cache clear" for k, v in fullKey.items(): #print "--> %r %r" % (k, v) greps.append(_shellQuote("%r %r" % (k, v))) cmd = ('%(find)s %(names)s -name "*.cache" | %(sed)s ' "'s/.cache$/.key/' ") % { 'find': Configuration.findCommand, 'names': names, 'sed': Configuration.sedCommand } cmd += "|" + " | ".join([ "%s %s -l %s" % (Configuration.xargsCommand, Configuration.fgrepCommand, i) for i in greps ]) LOG('running command %s' % cmd) ret, out = commands.getstatusoutput(cmd) #LOG('code %s, out %s' % (ret, out)) if ret: ERROR('Command "%s" returned %d, output:\n%s' % (cmd, ret, out)) return out = [ out[:-3] + 'cache' for i in out.split('\n') if len(i.strip()) and i[:6] != 'find: ' ] LOG('Expiring %s' % out) for i in out: _expireCacheFile(i)
def _getCompileCache(name, srcModTime, version): if srcModTime is None: srcModTime = _getDocRootModTime(name) cacheModTime = _getCompileCacheModTime(name) if cacheModTime > srcModTime or Configuration.runOutOfCache: try: ret, vsn = marshal.loads(_readCompileCacheRoot(name)) except ValueError: #marshal got bad shit ERROR('marshal.loads got bad stuff from compile cache, ignoring') return 0, _readDocRoot(name), srcModTime if vsn == version: return 1, ret, srcModTime else: DEBUG( CACHE, '_gcc() version mismatch, wanted %s, got %s, ' 'returning source' % (version, vsn)) return 0, _readDocRoot(name), srcModTime else: return 0, _readDocRoot(name), srcModTime