diff --git a/main.go b/main.go index 34496e5..1790b1d 100644 --- a/main.go +++ b/main.go @@ -161,12 +161,20 @@ func init() { func main() { var UC MetadataCache UC.objects = make(map[int64]metadataObject) - UC.sizeLimit = 100 + UC.sizeLimit = 5000 UC.objectType = "u" var PC MetadataCache PC.objects = make(map[int64]metadataObject) - PC.sizeLimit = 100 + PC.sizeLimit = 5000 PC.objectType = "p" + var TC MetadataCache + TC.objects = make(map[int64]metadataObject) + TC.sizeLimit = 5000 + TC.objectType = "p" + var CC MetadataCache + CC.objects = make(map[int64]metadataObject) + CC.sizeLimit = 100 + CC.objectType = "p" if err := os.RemoveAll(*sockpath); err != nil { log.Fatal(err) @@ -181,7 +189,7 @@ func main() { if err != nil { // handle error } - go handleConnection(conn, UC, PC) + go handleConnection(conn, UC, PC, TC, CC) } } @@ -192,7 +200,7 @@ type cachecommand struct { Command string `json:"c"` } -func handleConnection(conn net.Conn, UC MetadataCache, PC MetadataCache) { +func handleConnection(conn net.Conn, UC MetadataCache, PC MetadataCache, TC MetadataCache, CC MetadataCache) { log.Println("handleConnection started") var m *MetadataCache reader := bufio.NewReader(conn) @@ -211,10 +219,19 @@ func handleConnection(conn net.Conn, UC MetadataCache, PC MetadataCache) { log.Printf("json.Unmarshal: %s returned %s", buf, err.Error()) } var values []string - if c.ObjectType == "u" { - m = &UC - } else if c.ObjectType == "p" { - m = &PC + switch c.ObjectType { + case "u": + m=&UC + case "p": + m=&PC + case "t": + m=&TC + case "c": + m=&CC + default: + log.Printf("Invalid cache requested: %s\n", c.ObjectType) + conn.Close() + return } if c.Command == "g" { values, err = m.Get(c.ObjectId, c.Key)