X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=performance_schema%2Ffile_summary_by_instance%2Fcache.go;fp=performance_schema%2Ffile_summary_by_instance%2Fcache.go;h=6b2b14767e29519693218ac2e6a60737c6b51b30;hb=6befaeecc9554be09177e699544d9573e699f1c8;hp=0000000000000000000000000000000000000000;hpb=e0d7c6363deedafa29d8cc35e34cec6e056af2a9;p=pstop.git diff --git a/performance_schema/file_summary_by_instance/cache.go b/performance_schema/file_summary_by_instance/cache.go new file mode 100644 index 0000000..6b2b147 --- /dev/null +++ b/performance_schema/file_summary_by_instance/cache.go @@ -0,0 +1,36 @@ +package file_summary_by_instance + +import ( + "errors" + + // "github.com/sjmudd/pstop/lib" +) + +// provide a mapping from filename to table.schema etc + +var ( + mapped_name map[string]string + total, matched int +) + +func init() { + // setup on startup + mapped_name = make(map[string]string) +} + +func get_from_cache(key string) (result string, err error) { + total++ + if result, ok := mapped_name[key]; ok { + matched++ + // lib.Logger.Println("matched/total:", matched, total) + return result, nil + } else { + // lib.Logger.Println("matched/total:", matched, total) + return "", errors.New("Not found") + } +} + +func save_to_cache(key, value string) string { + mapped_name[key] = value + return value +}