LRUCacheGo 緩存庫(kù)
用 Go 編寫(xiě)的一個(gè)簡(jiǎn)單的 LRUCache 庫(kù),示例代碼:
// define a type that can be used with the cache
type myCacheableValue struct {
}
func (v *myCacheableValue) Size() uint64 {
return 64
}
// create a LRUCache
cache := lrucache.New(1989)
// put value to the cache
value := myCacheableValue{}
cache.Set("key", value)
// get value from the cache
v, ok := cache.Get("key")評(píng)論
圖片
表情
