{"id":15330487,"url":"https://github.com/kezhuw/leveldb","last_synced_at":"2025-10-07T12:05:12.486Z","repository":{"id":141204499,"uuid":"58838292","full_name":"kezhuw/leveldb","owner":"kezhuw","description":"LevelDB implementation in Go with clean interfaces.","archived":false,"fork":false,"pushed_at":"2020-02-21T13:17:31.000Z","size":291,"stargazers_count":13,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-15T02:54:26.166Z","etag":null,"topics":["database","go","leveldb"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kezhuw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-15T01:27:56.000Z","updated_at":"2023-07-25T01:21:03.000Z","dependencies_parsed_at":"2023-06-18T23:25:41.359Z","dependency_job_id":null,"html_url":"https://github.com/kezhuw/leveldb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kezhuw/leveldb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezhuw%2Fleveldb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezhuw%2Fleveldb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezhuw%2Fleveldb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezhuw%2Fleveldb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kezhuw","download_url":"https://codeload.github.com/kezhuw/leveldb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezhuw%2Fleveldb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278770820,"owners_count":26042853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","go","leveldb"],"created_at":"2024-10-01T09:53:25.864Z","updated_at":"2025-10-07T12:05:12.459Z","avatar_url":"https://github.com/kezhuw.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LevelDB implementation in pure Go\nThis is a LevelDB implementation, written in pure Go.\n\n[![Build Status](https://travis-ci.org/kezhuw/leveldb.svg?branch=master)](https://travis-ci.org/kezhuw/leveldb)\n[![Go Report Card](https://goreportcard.com/badge/github.com/kezhuw/leveldb)](https://goreportcard.com/report/github.com/kezhuw/leveldb)\n[![codecov](https://codecov.io/gh/kezhuw/leveldb/branch/master/graph/badge.svg)](https://codecov.io/gh/kezhuw/leveldb)\n[![GoDoc](https://godoc.org/github.com/kezhuw/leveldb?status.svg)](http://godoc.org/github.com/kezhuw/leveldb)\n\n**This project is in early stage of development, and should not be considered as stable. Don't use it in production!**\n\n\n## Goals\nThis project aims to write an pure Go implementation for LevelDB. It conforms to LevelDB storage format, but not\nimplementation details of official. This means that there may be differences in implementation with official.\n\n\n## Features\n\n- **Clean interface**  \nThe only exporting package is the top level package. All other packages are internal, and should not used by clients.\n\n- **Concurrent compactions**  \nClient can control concurrency of compactions through CompactionConcurrency option.\n\n\n## Usage\n\n### Create or open a database\n```go\noptions := \u0026leveldb.Options{\n\tCreateIfMissing: true,\n\t// ErrorIfExists:   true,\n\t// Filter: leveldb.NewBloomFilter(16),\n}\ndb, err := leveldb.Open(\"dbname\", options)\nif err != nil {\n\t// Handing failure\n}\ndefer db.Close()\n```\n\n### Reads and writes\n```go\nvar db *leveldb.DB\nvar err error\nvar key, value []byte\n\n// Put key value pair to db\nerr = db.Put(key, value, nil)\n\n// Read key's value from db\nvalue, err = db.Get(key, nil)\nif err == leveldb.ErrNotFound {\n\t// Key not found\n}\n\n// Delete key from db\nerr = db.Delete(key, nil)\n```\n\n### Batch writes\n```go\nvar db *leveldb.DB\nvar err error\nvar key, value []byte\n\nvar batch leveldb.Batch\nbatch.Put(key, value)\nbatch.Delete(key)\n\nerr = db.Write(batch, nil)\n```\n\n\n### Iteration\n```go\nvar db *leveldb.DB\nvar it leveldb.Iterator\nvar err error\nvar start, limit, prefix []byte\n\n// All keys from db\nit = db.All(nil)\ndefer it.Close()\nfor it.Next() {\n\tfmt.Printf(\"key: %x, value: %x\\n\", it.Key(), it.Value())\n}\nerr = it.Err()\n\n\n// All keys greater than or equal to given key from db\nit = db.Find(start, nil)\ndefer it.Close()\nfor it.Next() {\n}\nerr = it.Err()\n\n\n// All keys in range [start, limit) from db\nit = db.Range(start, limit, nil)\ndefer it.Close()\nfor it.Next() {\n}\nerr = it.Err()\n\n\n// All keys starts with prefix from db\nit = db.Prefix(prefix, nil)\ndefer it.Close()\nfor it.Next() {\n}\nerr = it.Err()\n```\n\n### Snapshots\n```go\nvar db *leveldb.DB\nvar key, start, limit, prefix []byte\n\nsnapshot := db.GetSnapshot()\ndefer snapshot.Close()\n\n// Dup an snapshot for usage in another goroutine\ngo func(ss *leveldb.Snapshot) {\n\tdefer ss.Close()\n\tit := ss.Prefix(prefix, nil)\n\tdefer it.Close()\n\tfor it.Next() {\n\t}\n}(snapshot.Dup())\n\n\n// Use snapshot in this goroutine\nvalue, err := snapshot.Get(key, nil)\n\nit := snapshot.Range(start, limit, nil)\ndefer it.Close()\nfor it.Next() {\n}\n```\n\n## Benchmarks\nSee [kezhuw/go-leveldb-benchmarks][go-leveldb-benchmarks].\n\n## TODO\n- [ ] Source code documentation [WIP]\n- [ ] Tests [WIP]\n- [ ] Logging\n- [ ] Abstract cache interface, so we can share cache among multiple LevelDB instances\n- [x] Reference counting openning file collection, don't rely on GC\n- [ ] Statistics\n- [x] Benchmarks, See [kezhuw/go-leveldb-benchmarks][go-leveldb-benchmarks].\n- [x] Concurrent level compaction\n- [ ] Replace hardcoded constants with configurable options\n- [ ] Automatic adjustment of volatile options\n\n\n## License\nThe MIT License (MIT). See [LICENSE](LICENSE) for the full license text.\n\n\n## Contribution\nBefore going on, make sure you agree on [The MIT License (MIT).](LICENSE).\n\nThis project is far from complete, lots of things are missing. If you find any bugs or complement any parts of missing,\nthrow me a pull request.\n\n\n## Acknowledgments\n* [google/leveldb](https://github.com/google/leveldb) Official implementation written in in C++.  \n  My knownledge of LevelDB storage format and implementation details mainly comes from this implementation.\n\n* [syndtr/goleveldb](https://github.com/syndtr/goleveldb) Complete and stable Go implementation.  \n  The `DB.Range`, `DB.Prefix`, and `filter.Generator` interface origin from this implementation.\n\n* [golang/leveldb](https://github.com/golang/leveldb) Official but incomplete Go implementation.  \n  The `Batch` and `Comparator.AppendSuccessor` origins from this implementation.\n\n[go-leveldb-benchmarks]: https://github.com/kezhuw/go-leveldb-benchmarks\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkezhuw%2Fleveldb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkezhuw%2Fleveldb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkezhuw%2Fleveldb/lists"}