https://github.com/bmwx4/lrucache
lrucache implement with double list and hash map in golang
https://github.com/bmwx4/lrucache
golang lrucache
Last synced: 27 days ago
JSON representation
lrucache implement with double list and hash map in golang
- Host: GitHub
- URL: https://github.com/bmwx4/lrucache
- Owner: bmwx4
- Created: 2019-07-11T05:02:06.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-11T05:19:10.000Z (almost 7 years ago)
- Last Synced: 2025-12-19T02:19:56.658Z (6 months ago)
- Topics: golang, lrucache
- Language: Go
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lrucache
### usage
```go
import "github.com/bmwx4/lrucache"
func main(){
c := lrucache.NewLRUCache(2)
c.Put(1)
...
c.Get(1)
lrucache.CleanLRUCache()
}
```
### test case
测试容量为1 的场景,添加和查询node:
```sh
go test -v -run Test_1
=== RUN Test_1
--- PASS: Test_1 (0.00s)
lru_cache_test.go:24: true
lru_cache_test.go:25: true
lru_cache_test.go:27: [{2 2}]
PASS
ok lru-cache 0.013s
```
测试容量为0 的场景,添加和查询node:
```sh
go test -v -run Test_2
=== RUN Test_2
--- PASS: Test_2 (0.00s)
lru_cache_test.go:37: true
lru_cache_test.go:38: true
lru_cache_test.go:41: true
lru_cache_test.go:42: true
PASS
ok lru-cache 0.013s
```