auth/vendor/github.com/savsgio/dictpool/README.md
Maxim Lebedev dcf9e3c2ca
Some checks failed
continuous-integration/drone/push Build is failing
📌 Vendored dependencies
2022-06-09 22:35:23 +05:00

1.1 KiB

dictpool

Test status
Go Report Card
GoDev

Memory store like map[string]interface{} with better performance when reuse memory.

Very useful when reuse memory (sync.Pool) to avoid extra allocations and increase the performance.

Benchmarks:

BenchmarkDict-12    	100000000	        12.08 ns/op	       0 B/op	       0 allocs/op
BenchmarkStdMap-12    	71028591	        21.23 ns/op	       0 B/op	       0 allocs/op

Benchmark with Go 1.17

Example:

d := dictpool.AcquireDict()
// d.BinarySearch = true  // Useful on big heaps

key := "foo"

d.Set(key, "Hello DictPool")

if d.Has(key){
    fmt.Println(d.Get(key))  // Output: Hello DictPool
}

d.Del(key)

dictpool.ReleaseDict(d)