https://github.com/night-codes/bcache
Golang small cache library
https://github.com/night-codes/bcache
Last synced: 3 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 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-02T05:21:49.000Z (over 9 years ago)
- Last Synced: 2025-01-23T23:32:55.532Z (4 months ago)
- Language: Go
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- 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 mainimport (
"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")) // 888time.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 2004Copyright (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 MODIFICATION0. You just DO WHAT THE FUCK YOU WANT TO.