sniper
A simple and efficient thread-safe key/value store for Go.
To start using sniper
, install Go and run go get
:
$ go get -u github.com/recoilme/sniper
This will retrieve the library.
The Sniper
includes this methods:
Set
, Get
, Incr
, Decr
, Delete
, Count
, Open
, Close
, FileSize
, Backup
.
s, _ := sniper.Open(sniper.Dir("1"))
s.Set([]byte("hello"), []byte("go"))
res, _ = s.Get([]byte("hello"))
fmt.Println(res)
s.Close()
// Output:
// go
MacBook Pro 2019 (Quad-Core Intel Core i7 2,8 GHz, 16 ГБ, APPLE SSD AP0512M)
go version go1.14 darwin/amd64
number of cpus: 8
number of keys: 10000000
keysize: 10
random seed: 1570109110136449000
-- sniper --
set: 10,000,000 ops over 8 threads in 63159ms, 158,331/sec, 6315 ns/op, 644.3 MB, 67 bytes/op
get: 10,000,000 ops over 8 threads in 4455ms, 2,244,629/sec, 445 ns/op, 305.5 MB, 32 bytes/op
del: 10,000,000 ops over 8 threads in 37568ms, 266,182/sec, 3756 ns/op, 122.8 MB, 12 bytes/op
With fsync
set: 10,000,000 ops over 8 threads in 85088ms, 117,524/sec, 8508 ns/op, 644.4 MB, 67 bytes/op
get: 10,000,000 ops over 8 threads in 5623ms, 1,778,268/sec, 562 ns/op, 305.5 MB, 32 bytes/op
hash(key) -> (value addr, value size)
, map. len(key) + len(value)
How to Change Open Files Limit on OS X and macOS
Vadim Kulibaba @recoilme
sniper
source code is available under the MIT License.