{"id":16920484,"url":"https://github.com/ostafen/rocketdb","last_synced_at":"2025-07-09T18:11:16.150Z","repository":{"id":234080449,"uuid":"628649606","full_name":"ostafen/rocketdb","owner":"ostafen","description":"Distributed transactional key value store backed by Redis.","archived":false,"fork":false,"pushed_at":"2023-04-17T13:23:45.000Z","size":6,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T12:51:03.881Z","etag":null,"topics":["database","distributed-database","golang","in-memory-caching","in-memory-database","key-value-store","redis","transaction","transactions"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ostafen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-04-16T15:54:49.000Z","updated_at":"2023-05-04T21:18:17.000Z","dependencies_parsed_at":"2024-04-18T05:09:07.570Z","dependency_job_id":"1b0dbdcd-4b24-4c68-8de3-f67fdb48efa6","html_url":"https://github.com/ostafen/rocketdb","commit_stats":null,"previous_names":["ostafen/rocketdb"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ostafen%2Frocketdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ostafen%2Frocketdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ostafen%2Frocketdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ostafen%2Frocketdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ostafen","download_url":"https://codeload.github.com/ostafen/rocketdb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248441905,"owners_count":21104099,"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":["database","distributed-database","golang","in-memory-caching","in-memory-database","key-value-store","redis","transaction","transactions"],"created_at":"2024-10-13T19:48:29.501Z","updated_at":"2025-04-11T16:39:27.189Z","avatar_url":"https://github.com/ostafen.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RocketDB :rocket:\n\n# Motivations\n\nRedis approach to transactions is based on a check-and-set (**CAS**) behavior provided by the **WATCH** command, which accepts a list of keys. The **WATCH** command is usually followed by a **MULTI**-**EXEC** block, which is only executed if any of the watched keys has been modified in the meantime by any other concurrent transaction. For example:\n```\nWATCH mykey\nval = GET mykey\nval = val + 1\nMULTI\nSET mykey $val\nEXEC\n```\n\nWhile **WATCH** can be called multiple times before the committing the transaction, serializability can be achieved only if the full set of keys to be watched is known in advance and passed to the first **WATCH** call.\n\n**RocketDB** is meant to unlock the full power of Redis transactions while providing an easy to use interface.\n\n# Installation\n\nTo start using RocketDB, type the following command:\n```bash\n$ go get -u github.com/ostafen/rocketdb\n```\n\n# Opening a database\n\n```go\nimport (\n    \"github.com/ostafen/rocketdb\"\n)\n\nconst (\n    host = \"localhost\"\n    port = 6379\n)\n\nfunc main() {\n    db, err := rocketdb.New(redis.NewClient(\u0026redis.Options{\n\t\tAddr:     fmt.Sprintf(\"%s:%d\", host, port),\n\t\tPassword: \"\",\n\t\tDB:       0,\n\t}))\n    if err != nil {\n        log.Fatal(err)\n    }\n    defer db.Close()\n\n    ...\n}\n```\n\n# Transactions\n\nThe easiest way to start a new (read-write) transaction is to use the `Update()` method\n\n```go\nerr := db.Update(func(tx *rocketdb.Tx) error {\n    ...\n    tx.Set(\"key\", \"value\")\n    ...\n    tx.Remove(\"key1\")\n    return nil\n})\n```\n\nor, for read-only transactions, the `View()` method:\n\n```go\nerr := db.View(func(tx *rocketdb.Tx) error {\n    ...\n    value, _ := tx.Get(\"key\")\n    ...\n    return nil\n})\n```\n\nSometimes you may want to take care of transaction managment. In those cases, you can use the `Begin()` method to get a new transaction:\n\n```go\ntx, err := db.Begin(context.Background(), true) // start a new writable transaction with the provided context\nif err != nil {\n    return err\n}\n...\n```\n\n# Contact\n\nStefano Scafiti @ostafen\n\n# Licence\nRocketDB source code is available under the **MIT License**.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fostafen%2Frocketdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fostafen%2Frocketdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fostafen%2Frocketdb/lists"}