{"id":28349723,"url":"https://github.com/mkch/hashive","last_synced_at":"2026-04-26T20:32:05.929Z","repository":{"id":282824902,"uuid":"949740990","full_name":"mkch/hashive","owner":"mkch","description":"A read-only key-value database.","archived":false,"fork":false,"pushed_at":"2025-04-07T15:25:53.000Z","size":237,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-19T04:38:06.434Z","etag":null,"topics":["database","golang","key-value-database","key-value-store"],"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/mkch.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,"zenodo":null}},"created_at":"2025-03-17T04:07:14.000Z","updated_at":"2025-03-30T07:03:12.000Z","dependencies_parsed_at":"2025-06-19T04:31:13.782Z","dependency_job_id":"89f8393b-0807-442c-a8f3-e0d5c8f61163","html_url":"https://github.com/mkch/hashive","commit_stats":null,"previous_names":["mkch/hashive"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mkch/hashive","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fhashive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fhashive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fhashive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fhashive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkch","download_url":"https://codeload.github.com/mkch/hashive/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fhashive/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32312252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T19:15:34.056Z","status":"ssl_error","status_checked_at":"2026-04-26T19:15:15.467Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","golang","key-value-database","key-value-store"],"created_at":"2025-05-27T20:10:58.100Z","updated_at":"2026-04-26T20:32:05.924Z","avatar_url":"https://github.com/mkch.png","language":"Go","readme":"# Hashive\n\n[简体中文](README.zh-CN.md)\n\nHashive is a single-file, read-only key-value database.\n\nIn simple terms, a Hashive database is essentially a `map[string]any` stored in a file, allowing for fast lookups without the need to load the entire file into memory.\n\n## Design Goals\n\n1. Single-file Database\n\n    A Hashive database is a single file that can be queried without needing to load the entire file into memory.\n\n2. Lightweight\n\n    No additional configuration steps are required; it works out of the box. It does not significantly increase the complexity of the entire system.\n\n3. Speed\n\n    Hashive aims to achieve query speeds comparable to (or faster than) other databases.\n\n4. Key-Value Query\n\n    Hashive only stores key-value data. Values are queried using string-type keys.\n\n5. Read-Only\n\n    Hashive is optimized for read-only operations. More complex and slower write operations can be traded off for faster query speeds. In practice, a Hashive database is typically written (generated) only once.\n\nIt is evident that the first three design goals highly overlap with those of the SQLite database. However, SQLite is not a key-value database nor a read-only, and it lacks optimizations for key-value queries and read-only datasets. The third and fourth points highly overlap with hash tables, but hash tables require loading the entire dataset into memory to be usable. Hashive aims to find a balance between SQLite and in-memory hash tables, specifically optimized for read-only datasets.\n\n## Features\n\n1. Performance\n\n    In specific scenarios, Hashive's query speed is 5 times faster than that of an SQLite3 database with the same content.\n\n    Benchmark(3 random queries):\n\n    ```text\n    Hashive    110955   10112 ns/op   568 B/op    21 allocs/op\n    SQLite     22893    51927 ns/op   1760 B/op   57 allocs/op\n    ```\n\n2. Direct Storage of Any Go Value\n\n    In addition to commonly used types such as integers, floating-point numbers, strings, arrays, and associative objects (hash maps), any type supported by `encoding/gob` can be stored as a value.\n\n## Example\n\n```go\npackage hashive_test\n\nimport (\n    \"fmt\"\n    \"os\"\n\n    \"github.com/mkch/hashive\"\n)\n\ntype Description struct {\n    Content string\n}\n\nfunc Example() {\n    value := map[string]any{\n        \"Key1\": 123,\n        \"Key2\": \"456\",\n        \"Owners\": []any{\n            map[string]any{\n                \"Name\": \"John\",\n                \"Age\":  28,\n            },\n            map[string]any{\n                \"Name\": \"Joe\",\n                \"Age\":  29,\n                \"Addr\": \"abc street\",\n            },\n        },\n        \"Description\": Description{\"description here\"},\n    }\n\n    const DB_FILE = \"testdata/db\"\n    // Write\n    err := hashive.WriteFile(DB_FILE, value)\n    if err != nil {\n        panic(err)\n    }\n    defer os.Remove(DB_FILE)\n\n    // Read\n    db, close, err := hashive.Open(DB_FILE, -1)\n    if err != nil {\n        panic(err)\n    }\n    defer close()\n\n    v1, _ := db.Query(\"Key1\") // db.Key1\n    fmt.Println(v1)\n    v2, _ := db.Query(\"Key2\") // db.Key2\n    fmt.Println(v2)\n    var desc Description\n    err = db.QueryGob(\u0026desc, \"Description\") // db.Description\n    fmt.Println(desc)\n    name, _ := db.Query(\"Owners\", \"0\", \"Name\") // db.Owners[0].Name\n    fmt.Println(name)\n    addr, _ := db.Query(\"Owners\", \"1\", \"Addr\") // db.Owners[1].Addr\n    fmt.Println(addr)\n\n    // Output:\n    // 123\n    // 456\n    // {description here}\n    // John\n    // abc street\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkch%2Fhashive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkch%2Fhashive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkch%2Fhashive/lists"}