{"id":18418612,"url":"https://github.com/bsm/ccdb","last_synced_at":"2025-10-28T22:11:08.769Z","repository":{"id":31732415,"uuid":"35298391","full_name":"bsm/ccdb","owner":"bsm","description":null,"archived":false,"fork":false,"pushed_at":"2017-03-30T10:58:45.000Z","size":21,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T05:54:50.455Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/bsm.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}},"created_at":"2015-05-08T19:42:17.000Z","updated_at":"2020-04-15T07:56:30.000Z","dependencies_parsed_at":"2022-08-29T15:52:12.861Z","dependency_job_id":null,"html_url":"https://github.com/bsm/ccdb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fccdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fccdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fccdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fccdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bsm","download_url":"https://codeload.github.com/bsm/ccdb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670502,"owners_count":21142901,"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","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":[],"created_at":"2024-11-06T04:14:07.675Z","updated_at":"2025-10-28T22:11:03.713Z","avatar_url":"https://github.com/bsm.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ccdb\n\n[![Build Status](https://travis-ci.org/bsm/ccdb.png)](https://travis-ci.org/bsm/ccdb)\n[![GoDoc](https://godoc.org/github.com/bsm/ccdb?status.png)](http://godoc.org/github.com/bsm/ccdb)\n[![Go Report Card](https://goreportcard.com/badge/github.com/bsm/ccdb)](https://goreportcard.com/report/github.com/bsm/ccdb)\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\nccdb is a pure Go library to read and write ccdb (\"continuous constant database\") databases.\nIt is an adaptation of D. J. Bernstein's [cdb](http://cr.yp.to/cdb.html) design, inspired by\nideas taken from [sparkey](https://github.com/spotify/sparkey).\n\n## Features\n\n* Written in pure [Go](http://golang.org), no dependencies beyond stdlib.\n* All the features of [cdb](http://cr.yp.to/cdb.html) fast \u0026 simple.\n* Multiple values per key.\n* Databases are thread-safe.\n* Support for multiple, concurrent readers.\n* Data is always appended and never replaced.\n* Closed databases can be re-opened and appended to.\n* Values can be streamed (`io.Reader`).\n* Log and index are stored in separate files as proposed by [sparkey](https://github.com/spotify/sparkey#design): \"The advantages of having two files instead of just one is that it's trivial to mlock one of the files and not the other. It also enables us to append more data to existing log files, even after it's already in use.\"\n\n## Documentation\n\nCheck out the full API on [godoc.org](http://godoc.org/github.com/bsm/ccdb).\n\n## Workflow\n\nFirst, write/append your data to a log. You can index your logs:\n\n```go\nimport(\n  \"fmt\"\n  \"os\"\n  \"path/filepath\"\n\n  \"github.com/bsm/ccdb\"\n)\n\nfunc main() {\n\terr := os.MkdirAll(\"testdata/example\", 0755)\n\thandleError(err)\n\tdefer os.RemoveAll(\"testdata/example\")\n\n\t// Open a new log file\n\tlog, err := ccdb.CreateLog(\"testdata/example/db.ccl\")\n\thandleError(err)\n\n\t// Append data\n\terr = log.Put([]byte(\"foo\"), []byte(\"value1\"))\n\thandleError(err)\n\terr = log.Put([]byte(\"foo\"), []byte(\"value2\"))\n\thandleError(err)\n\n\t// Close log\n\terr = log.Close()\n\thandleError(err)\n\n\t// Re-open a log file, append more data\n\tlog, err = ccdb.AppendLog(\"testdata/example/db.ccl\")\n\thandleError(err)\n\tdefer log.Close()\n\n\terr = log.Put([]byte(\"bar\"), []byte(\"othervalue\"))\n\thandleError(err)\n\n\t// Create an index spapshot\n\terr = log.WriteIndex(\"testdata/example/db.cci\")\n\thandleError(err)\n\n\t// Close log again\n\terr = log.Close()\n\thandleError(err)\n\n\t// Read entries\n\tentries, err := filepath.Glob(\"testdata/example/*\")\n\thandleError(err)\n\tfmt.Println(entries)\n\n}\n```\n\nOpen the DB for reading:\n\n```go\nimport (\n  \"fmt\"\n\n  \"github.com/bsm/ccdb\"\n)\n\nfunc main() {\n\t// Open a database for reading\n\tdb, err := ccdb.Open(\"testdata/data.cci\", \"testdata/data.ccl\")\n\thandleError(err)\n\tdefer db.Close()\n\n\t// Iterate over the values of a key\n\titer, err := db.Get([]byte(\"foo\"))\n\thandleError(err)\n\n\tfmt.Println(\"\\nKEY: foo\")\n\tfor iter.Next() {\n\t\tval, _ := iter.Value()\n\t\tfmt.Println(string(val))\n\t}\n\tfmt.Println(\"ERROR:\", iter.Error())\n\n\t// Or, read them all\n\titer, err = db.Get([]byte(\"bar\"))\n\thandleError(err)\n\n\tfmt.Println(\"\\nKEY: bar\")\n\tvals, err := iter.All()\n\thandleError(err)\n\tfor _, val := range vals {\n\t\tfmt.Println(string(val))\n\t}\n\tfmt.Println(\"ERROR:\", iter.Error())\n\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsm%2Fccdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbsm%2Fccdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsm%2Fccdb/lists"}