https://github.com/night-codes/bcache
Golang small cache library
https://github.com/night-codes/bcache
Last synced: 8 months ago
JSON representation
Golang small cache library
- Host: GitHub
- URL: https://github.com/night-codes/bcache
- Owner: night-codes
- License: wtfpl
- Created: 2015-12-01T20:39:37.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-12-02T05:21:49.000Z (over 10 years ago)
- Last Synced: 2025-03-17T13:46:53.104Z (over 1 year ago)
- Language: Go
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bcache
Golang small cache library
## Use
```golang
package main
import (
"fmt"
"github.com/mirrr/bcache"
"time"
)
func main() {
cache := bcache.Create()
cache.Updater(func(key string) interface{} {
if key == "mykey" {
return 777
}
return nil
})
cache.Set("mykey2", 888)
fmt.Println(cache.Get("mykey")) // 777
fmt.Println(cache.Get("mykey2")) // 888
time.Sleep(time.Second * 2)
fmt.Println(cache.Get("mykey")) // 777
fmt.Println(cache.Get("mykey2")) //
}
```
\* Any key kept in cache no longer than a second. Byt upon receipt of the value life time is extended for a second.
## Documentation
[Docs on godoc.org](https://godoc.org/github.com/mirrr/bcache)
## License
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2015 Oleksiy Chechel
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.