https://github.com/hlts2/gocache
Ultra fast lock-free cache library
https://github.com/hlts2/gocache
cache cache-library fast fastest go gocache golang goroutine-safe hlts2 key-value kvs lock-free simple ultrafast
Last synced: about 1 year ago
JSON representation
Ultra fast lock-free cache library
- Host: GitHub
- URL: https://github.com/hlts2/gocache
- Owner: hlts2
- License: mit
- Created: 2018-07-24T15:38:46.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2024-01-24T01:24:57.000Z (over 2 years ago)
- Last Synced: 2025-04-09T23:14:31.916Z (about 1 year ago)
- Topics: cache, cache-library, fast, fastest, go, gocache, golang, goroutine-safe, hlts2, key-value, kvs, lock-free, simple, ultrafast
- Language: Go
- Homepage:
- Size: 590 KB
- Stars: 9
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gocache [](https://opensource.org/licenses/MIT) [](https://goreportcard.com/report/github.com/hlts2/gocache) [](https://gitter.im/hlts2/gocache?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [](http://godoc.org/github.com/hlts2/gocache)
gocache is simple ultra fast lock-free cache library written in golang.
## Requirement
Go (>= 1.9)
## Installation
```shell
go get github.com/hlts2/gocache
```
## Example
### Basic Example
`Set` is `Set(key string, value interface{})`, so you can set any type of object.
```go
var (
key1 = "key_1"
key2 = "key_2"
key3 = "key_3"
value1 = "value_1"
value2 = 1234
value3 = struct{}{}
)
cache := gocache.New()
// default expire is 50 Seconds
ok := cache.Set(key1, value1) // true
ok := cache.Set(key2, value2) // true
ok := cache.Set(key3, value3) // true
// get cached data
v, ok := cache.Get(key1)
v, ok := cache.Get(key2)
v, ok := cache.Get(key3)
```
## Benchmarks
[gocache](https://github.com/hlts2/gocache) vs [go-cache](https://github.com/patrickmn/go-cache) vs [gache](https://github.com/kpango/gache) vs [gcache](https://github.com/bluele/gcache)
The version of golang is `go1.10.3 linux/amd64`

## Author
[hlts2](https://github.com/hlts2)
## LICENSE
gocache released under MIT license, refer [LICENSE](https://github.com/hlts2/gocache/blob/master/LICENSE) file.