def get_cachestatus(req, path, params, data): atime = time.time() timetable = [] d = {} d['status'] = 'ok' d['html_response_code'] = '200' d['timetable'] = timetable req.reply_headers['Content-Type'] = "text/plain" + "; charset=utf-8" atime = time.time() s = '\r\n\r\nresultcache content: %s\r\n' % cache_date2string( time.time(), '%04d-%02d-%02d-%02d-%02d-%02d') s += resultcache.report() d['timetable'].append( ["retrieved report for resultcache", time.time() - atime]) atime = time.time() req.write(s) d['timetable'].append( ["writing cache reports to request", time.time() - atime]) atime = time.time() return d['html_response_code'], len(s), d
def flush_maskcache(req=None): global maskcache, maskcache_accesscount, maskcache_shallow, maskcache_msg logging.getLogger("everything").info("going to flush maskcache, content is: \r\n" + get_maskcache_report()) maskcache = {} maskcache_accesscount = {} maskcache_shallow = {} if req: user = users.getUserFromRequest(req) logging.getLogger("everything").info("flush of masks cache triggered by user %s with request on '%s'" % (user.name, req.path)) sys.stdout.flush() maskcache_msg = '| cache last flushed %s\r\n|\r\n' % cache_date2string(time.time(), '%04d-%02d-%02d-%02d-%02d-%02d')
def flush_maskcache(req=None): global maskcache, maskcache_accesscount, maskcache_shallow, maskcache_msg logging.getLogger("everything").info( "going to flush maskcache, content is: \r\n" + get_maskcache_report()) maskcache = {} maskcache_accesscount = {} maskcache_shallow = {} if req: user = users.getUserFromRequest(req) logging.getLogger("everything").info( "flush of masks cache triggered by user %s with request on '%s'" % (user.name, req.path)) sys.stdout.flush() maskcache_msg = '| cache last flushed %s\r\n|\r\n' % cache_date2string( time.time(), '%04d-%02d-%02d-%02d-%02d-%02d')
# for TAL templates from mask cache context = default_context.copy() context['host'] = "http://" + config.get("host.name") DEFAULT_MASKCACHE = 'deep' # 'deep' | 'shallow' | None # remark 2013-09-18 wn: only deep cache compatible with multilingual text/memo/htmlmemo fields def init_maskcache(): global maskcache, maskcache_shallow, maskcache_accesscount, maskcache_msg # for deep mask caching maskcache = {} maskcache_accesscount = {} maskcache_msg = '| cache initialized %s\r\n|\r\n' % cache_date2string( time.time(), '%04d-%02d-%02d-%02d-%02d-%02d') # for shallow mask caching maskcache_shallow = {} def get_maskcache_report(): s = maskcache_msg + "| %d lookup keys in cache, total access count: %d\r\n|\r\n" total_access_count = 0 for k, v in sorted(maskcache_accesscount.items()): s += "| %s : %s\r\n" % (k.ljust(60, '.'), str(v).rjust(8, '.')) total_access_count += v return s % (len(maskcache_accesscount), total_access_count) def flush_maskcache(req=None):
languages = [l.strip() for l in config.get("i18n.languages").split(",") if l.strip()] # for TAL templates from mask cache context = default_context.copy() context['host'] = "http://" + config.get("host.name") DEFAULT_MASKCACHE = 'deep' # 'deep' | 'shallow' | None # remark 2013-09-18 wn: only deep cache compatible with multilingual text/memo/htmlmemo fields def init_maskcache(): global maskcache, maskcache_shallow, maskcache_accesscount, maskcache_msg # for deep mask caching maskcache = {} maskcache_accesscount = {} maskcache_msg = '| cache initialized %s\r\n|\r\n' % cache_date2string(time.time(), '%04d-%02d-%02d-%02d-%02d-%02d') # for shallow mask caching maskcache_shallow = {} def get_maskcache_report(): s = maskcache_msg + "| %d lookup keys in cache, total access count: %d\r\n|\r\n" total_access_count = 0 for k, v in sorted(maskcache_accesscount.items()): s += "| %s : %s\r\n" % (k.ljust(60, '.'), str(v).rjust(8, '.')) total_access_count += v return s % (len(maskcache_accesscount), total_access_count) def flush_maskcache(req=None):