README
¶

gache is thinnest cache library for go application
Requirement
Go 1.11
Installation
go get github.com/kpango/gache
Example
// data sets
var (
key1 = "key"
key2 = 5050
key3 = struct{}{}
value1 = "value"
value2 = 88888
value3 = struct{}{}
)
// store cache default expire is 30 Seconds
gache.Set(key1, value3)
gache.Set(key2, value2)
gache.Set(key3, value1)
// load cache data
v1, ok := gache.Get(key1)
v2, ok := gache.Get(key2)
v3, ok := gache.Get(key3)
gache.Write(context.Background(), glg.FileWriter("./gache-sample.gdb", 0755))
gache.New().SetDefaultExpire(time.Minute).Read(glg.FileWriter("./gache-sample.gdb", 0755))
Benchmarks
gache vs gocache vs normal map with lock vs go-cache vs gcache vs freecache vs bigcache vs go-mcache
go test -count=1 -run=NONE -bench . -benchmem
goos: darwin
goarch: amd64
pkg: github.com/kpango/gache
BenchmarkGacheWithSmallDataset-8 5000000 250 ns/op 192 B/op 8 allocs/op
BenchmarkGacheWithBigDataset-8 500 3179552 ns/op 485156 B/op 20160 allocs/op
BenchmarkGocacheWithSmallDataset-8 3000000 378 ns/op 323 B/op 16 allocs/op
BenchmarkGocacheWithBigDataset-8 300 3564275 ns/op 815303 B/op 40352 allocs/op
BenchmarkFastCacheWithSmallDataset-8 1000000 1496 ns/op 44 B/op 4 allocs/op
BenchmarkFastCacheWithBigDataset-8 50 36815105 ns/op 126848505 B/op 41603 allocs/op
BenchmarkBigCacheWithSmallDataset-8 1000000 1915 ns/op 424 B/op 8 allocs/op
BenchmarkBigCacheWithBigDataset-8 30 62743673 ns/op 227737772 B/op 32892 allocs/op
BenchmarkFreeCacheWithSmallDataset-8 1000000 2659 ns/op 31 B/op 4 allocs/op
BenchmarkFreeCacheWithBigDataset-8 50 26550884 ns/op 126889120 B/op 41552 allocs/op
BenchmarkMapWithSmallDataset-8 500000 4221 ns/op 137 B/op 8 allocs/op
BenchmarkMapWithBigDataset-8 100 10926857 ns/op 358593 B/op 20808 allocs/op
BenchmarkGoCacheWithSmallDataset-8 500000 3870 ns/op 73 B/op 4 allocs/op
BenchmarkGoCacheWithBigDataset-8 100 10858366 ns/op 201482 B/op 10809 allocs/op
BenchmarkGCacheLRUWithSmallDataset-8 200000 7913 ns/op 348 B/op 16 allocs/op
BenchmarkGCacheLRUWithBigDataset-8 50 21157440 ns/op 2026806 B/op 61756 allocs/op
BenchmarkGCacheLFUWithSmallDataset-8 200000 10704 ns/op 542 B/op 20 allocs/op
BenchmarkGCacheLFUWithBigDataset-8 50 22017917 ns/op 1491388 B/op 51602 allocs/op
BenchmarkGCacheARCWithSmallDataset-8 200000 10987 ns/op 350 B/op 16 allocs/op
BenchmarkGCacheARCWithBigDataset-8 20 64480186 ns/op 3068799 B/op 84008 allocs/op
BenchmarkMCacheWithSmallDataset-8 100000 18578 ns/op 4373 B/op 41 allocs/op
BenchmarkMCacheWithBigDataset-8 30 34827645 ns/op 10851422 B/op 102187 allocs/op
BenchmarkBitcaskWithSmallDataset-8 30000 55917 ns/op 2455 B/op 49 allocs/op
BenchmarkBitcaskWithBigDataset-8 200 10602661 ns/op 10502332 B/op 11091 allocs/op
PASS
ok github.com/kpango/gache 67.249s
Contribution
- Fork it ( https://github.com/kpango/gache/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
Author
LICENSE
gache released under MIT license, refer LICENSE file.
Click to show internal directories.
Click to hide internal directories.