Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/syndtr/goleveldb
LevelDB key/value database in Go.
https://github.com/syndtr/goleveldb
database go leveldb
Last synced: 5 days ago
JSON representation
LevelDB key/value database in Go.
- Host: GitHub
- URL: https://github.com/syndtr/goleveldb
- Owner: syndtr
- License: bsd-2-clause
- Created: 2013-01-23T04:08:58.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2024-05-14T20:40:52.000Z (9 months ago)
- Last Synced: 2025-01-15T08:27:48.994Z (11 days ago)
- Topics: database, go, leveldb
- Language: Go
- Size: 1.87 MB
- Stars: 6,198
- Watchers: 181
- Forks: 969
- Open Issues: 108
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - goleveldb - Implementation of the [LevelDB](https://github.com/google/leveldb) key/value database in Go. (Database / Databases Implemented in Go)
- my-awesome - syndtr/goleveldb - 05 star:6.2k fork:1.0k LevelDB key/value database in Go. (Go)
- awesome-go-storage - goleveldb - An implementation of the [LevelDB](https://github.com/google/leveldb) key/value database in the Go. (Database)
- awesome-distributed-system-projects - goleveldb - a LevelDB implemented in Golang
- awesome-repositories - syndtr/goleveldb - LevelDB key/value database in Go. (Go)
- awesome-go - LevelDB - key/value database in Go. (Key/Value Databases)
- awesome-list - goleveldb
- go-awesome - leveldb - Go implementation of LevelDB (Open source library / Database)
- awesome-golang-repositories - goleveldb
- awesome-go - goleveldb - LevelDB key/value database in Go. - ★ 2578 (Database)
- awesome-go-extra - goleveldb - 01-23T04:08:58Z|2022-08-20T09:22:01Z| (Generators / Databases Implemented in Go)
- awesome-go-storage - goleveldb - An implementation of the [LevelDB](https://github.com/google/leveldb) key/value database in the Go. (Database)
- StarryDivineSky - syndtr/goleveldb
- awesome-go - goleveldb - Implementation of the [LevelDB](https://github.com/google/leveldb) key/value database in Go. Stars:`6.2K`. (Database / Databases Implemented in Go)
README
This is an implementation of the [LevelDB key/value database](https://github.com/google/leveldb) in the [Go programming language](https://go.dev).
[![Build Status](https://app.travis-ci.com/syndtr/goleveldb.svg?branch=master)](https://app.travis-ci.com/syndtr/goleveldb)
Installation
-----------go get github.com/syndtr/goleveldb/leveldb
Requirements
-----------* Need at least `go1.14` or newer.
Usage
-----------Create or open a database:
```go
// The returned DB instance is safe for concurrent use. Which mean that all
// DB's methods may be called concurrently from multiple goroutine.
db, err := leveldb.OpenFile("path/to/db", nil)
...
defer db.Close()
...
```
Read or modify the database content:
```go
// Remember that the contents of the returned slice should not be modified.
data, err := db.Get([]byte("key"), nil)
...
err = db.Put([]byte("key"), []byte("value"), nil)
...
err = db.Delete([]byte("key"), nil)
...
```Iterate over database content:
```go
iter := db.NewIterator(nil, nil)
for iter.Next() {
// Remember that the contents of the returned slice should not be modified, and
// only valid until the next call to Next.
key := iter.Key()
value := iter.Value()
...
}
iter.Release()
err = iter.Error()
...
```
Seek-then-Iterate:
```go
iter := db.NewIterator(nil, nil)
for ok := iter.Seek(key); ok; ok = iter.Next() {
// Use key/value.
...
}
iter.Release()
err = iter.Error()
...
```
Iterate over subset of database content:
```go
iter := db.NewIterator(&util.Range{Start: []byte("foo"), Limit: []byte("xoo")}, nil)
for iter.Next() {
// Use key/value.
...
}
iter.Release()
err = iter.Error()
...
```
Iterate over subset of database content with a particular prefix:
```go
iter := db.NewIterator(util.BytesPrefix([]byte("foo-")), nil)
for iter.Next() {
// Use key/value.
...
}
iter.Release()
err = iter.Error()
...
```
Batch writes:
```go
batch := new(leveldb.Batch)
batch.Put([]byte("foo"), []byte("value"))
batch.Put([]byte("bar"), []byte("another value"))
batch.Delete([]byte("baz"))
err = db.Write(batch, nil)
...
```
Use bloom filter:
```go
o := &opt.Options{
Filter: filter.NewBloomFilter(10),
}
db, err := leveldb.OpenFile("path/to/db", o)
...
defer db.Close()
...
```
Documentation
-----------You can read package documentation [here](https://pkg.go.dev/github.com/syndtr/goleveldb).