# lru **Repository Path**: gricks/lru ## Basic Information - **Project Name**: lru - **Description**: Library: lru cache - **Primary Language**: Go - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-04-19 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # lru Cache A lru Cache # Example ```golang package main import ( "fmt" "gitee.com/gricks/lru" ) func main() { c := lru.New(3) c.OnEvicted = func(key interface{}, val interface{}) { fmt.Println("remove:", key, val) } c.Add(1, "val1") c.Add(2, "val2") c.Add(3, "val3") c.Add(4, "val4") // remove 1 c.Down(4) c.Add(5, "val5") // remove 4 c.Get(2) c.Add(6, "val6") // remove 3 c.Clear() // remove all } ```