{"id":15476119,"url":"https://github.com/speed2exe/kvstore","last_synced_at":"2025-03-28T13:26:52.605Z","repository":{"id":183401137,"uuid":"657606803","full_name":"speed2exe/kvstore","owner":"speed2exe","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-24T08:54:28.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-19T02:30:16.727Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/speed2exe.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,"publiccode":null,"codemeta":null}},"created_at":"2023-06-23T12:35:03.000Z","updated_at":"2023-06-25T10:01:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"c3659b86-286f-4a9a-a3f9-1de86b6832ba","html_url":"https://github.com/speed2exe/kvstore","commit_stats":{"total_commits":14,"total_committers":3,"mean_commits":4.666666666666667,"dds":0.1428571428571429,"last_synced_commit":"0dcadce16f474edf0d12488dbbbdee179a04f3a6"},"previous_names":["speed2exe/kvstore"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speed2exe%2Fkvstore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speed2exe%2Fkvstore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speed2exe%2Fkvstore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/speed2exe%2Fkvstore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/speed2exe","download_url":"https://codeload.github.com/speed2exe/kvstore/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246036314,"owners_count":20713220,"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-10-02T03:22:51.488Z","updated_at":"2025-03-28T13:26:52.588Z","avatar_url":"https://github.com/speed2exe.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Generic Key Value store for rocksdb and dynomodb\n\n## Goal\n- Generic key value storage for custom defined key and value type\n\n## Usage\n- full example: `main.rs`\n\n- AWS dynomodb\n```toml\n[dependencies]\ntokio = { version = \"1.28\", features = [\"full\"] }\nkvstore = { git = \"https://github.com/speed2exe/kvstore\", branch = \"main\"}\nserde_json = \"1.0\"\nserde = { version = \"1.0\", features = [\"derive\"] }\n# rocksdb = \"0.21\"\naws-config = \"0.55\"\naws-sdk-dynamodb = \"0.28\"\n```\n\n```rust\nuse aws_config::meta::region::RegionProviderChain;\nuse aws_sdk_dynamodb::Client;\nuse kvstore::{dynamodb_kv::DynamoDBKVStore, KVStore};\nuse std::error::Error;\n\nuse serde::{Deserialize, Serialize};\n\nstruct CustomKey {\n    // ...\n}\n\nimpl kvstore::KeyString for CustomKey {\n    fn as_str(\u0026self) -\u003e String {\n        // unique string for this key\n    }\n}\n\nstruct CustomValue {\n    // ...\n}\n\n#[tokio::main]\nasync fn main() {\n    // ~/.aws/credentials\n    // [default]\n    // aws_access_key_id = \u003cyour access key\u003e\n    // aws_secret_access_key = \u003cyour secret key\u003e\n    let aws_dynomodb_client = {\n        let region_provider = RegionProviderChain::default_provider().or_else(\"ap-southeast-1\");\n        let config = aws_config::from_env().region(region_provider).load().await;\n        Client::new(\u0026config)\n    };\n    let mut dynamodb_store = DynamoDBKVStore::new(\n        aws_dynomodb_client,\n        \"your_table\".to_string(),\n        \"your_partition\".to_string(),\n        \"value_field\".to_string(), // can be fixed defined value\n    );\n\n    let key = CustomKey {\n        // ...\n    };\n    let value = CustomValue {\n        // ...\n    };\n\n    // put data\n    let put_res: Result\u003c(), Box\u003cdyn Error\u003e\u003e = kvstore.put(key, value).await;\n\n    // get data\n    let get_res: Result\u003cOption\u003cCustomValue\u003e, Box\u003cdyn Error\u003e\u003e = kvstore.get(\u0026key).await;\n\n    // delete data\n    let del_res: Result\u003c(), Box\u003cdyn Error\u003e\u003e = kvstore.delete(\u0026key2).await;\n\n    // check exist\n    let put_res: Result\u003cbool, Box\u003cdyn Error\u003e\u003e = kvstore.put(key, value).await;\n}\n```\n\n## Methodology\n- Uses a unique string to represent key\n- Uses JSON string to represent underlying values in various storage system\n\n## Requirements\n- custom key types need to implement `KeyString` trait\n```rust\nstruct CustomKey {\n    id: i32,\n    name: String,\n}\n\nimpl kvstore::KeyString for CustomKey {\n    fn as_str(\u0026self) -\u003e String {\n        format!(\"{}-{}\", self.id, self.name)\n    }\n}\n```\n\n- custom values need to implement `serde::{Deserialize, Serialize}` trait\n\n## Possible Future improvements\n- use `#![feature(async_fn_in_trait)]`\n- RWLock on `KeyString`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspeed2exe%2Fkvstore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspeed2exe%2Fkvstore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspeed2exe%2Fkvstore/lists"}