6b2b14767e29519693218ac2e6a60737c6b51b30
[pstop.git] / performance_schema / file_summary_by_instance / cache.go
1 package file_summary_by_instance
2
3 import (
4         "errors"
5
6         //      "github.com/sjmudd/pstop/lib"
7 )
8
9 // provide a mapping from filename to table.schema etc
10
11 var (
12         mapped_name    map[string]string
13         total, matched int
14 )
15
16 func init() {
17         // setup on startup
18         mapped_name = make(map[string]string)
19 }
20
21 func get_from_cache(key string) (result string, err error) {
22         total++
23         if result, ok := mapped_name[key]; ok {
24                 matched++
25                 //              lib.Logger.Println("matched/total:", matched, total)
26                 return result, nil
27         } else {
28                 //              lib.Logger.Println("matched/total:", matched, total)
29                 return "", errors.New("Not found")
30         }
31 }
32
33 func save_to_cache(key, value string) string {
34         mapped_name[key] = value
35         return value
36 }