https://github.com/lwch/l2cache
内存+磁盘缓存
https://github.com/lwch/l2cache
Last synced: 2 months ago
JSON representation
内存+磁盘缓存
- Host: GitHub
- URL: https://github.com/lwch/l2cache
- Owner: lwch
- Created: 2021-10-28T02:21:58.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-28T03:41:46.000Z (over 3 years ago)
- Last Synced: 2025-01-03T17:32:46.628Z (4 months ago)
- Language: Go
- Size: 1000 Bytes
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# l2cache
golang内存+磁盘缓存,扩展bytes.Buffer的能力,当数据量超过某个量级时降级缓存到磁盘上
## 使用方式
cache, err := cache.New(1024, os.TempDir())
if err != nil {
logging.Error("can not create cache: %v", err)
return
}
data := []byte("hello world")
_, err = cache.Write(data)
if err != nil {
logging.Error("can not write data: %v", err)
return
}
_, err = cache.Read(data)
if err != nil {
logging.Error("can not read data: %v", err)
return
}