{"id":13438499,"url":"https://github.com/aisk/rust-memcache","last_synced_at":"2025-05-15T10:01:17.682Z","repository":{"id":9437335,"uuid":"11312685","full_name":"aisk/rust-memcache","owner":"aisk","description":"memcache client for rust","archived":false,"fork":false,"pushed_at":"2025-02-12T15:09:29.000Z","size":323,"stargazers_count":140,"open_issues_count":21,"forks_count":41,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-09T18:01:16.797Z","etag":null,"topics":["cache","client","driver","memcache","memcached","rust","rust-memcache"],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/aisk.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":"2013-07-10T13:28:02.000Z","updated_at":"2025-05-02T00:31:35.000Z","dependencies_parsed_at":"2023-11-09T11:57:21.392Z","dependency_job_id":"927198fa-d751-4701-b35f-274cbfa966de","html_url":"https://github.com/aisk/rust-memcache","commit_stats":{"total_commits":347,"total_committers":21,"mean_commits":"16.523809523809526","dds":"0.19020172910662825","last_synced_commit":"8e270d8c7e4a73697eb066f8ae4c9b8c16845dd5"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aisk%2Frust-memcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aisk%2Frust-memcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aisk%2Frust-memcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aisk%2Frust-memcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aisk","download_url":"https://codeload.github.com/aisk/rust-memcache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319715,"owners_count":22051072,"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":["cache","client","driver","memcache","memcached","rust","rust-memcache"],"created_at":"2024-07-31T03:01:06.036Z","updated_at":"2025-05-15T10:01:16.477Z","avatar_url":"https://github.com/aisk.png","language":"Rust","readme":"# rust-memcache\n\n[![Crates.io](https://img.shields.io/crates/v/memcache.svg)](https://crates.io/crates/memcache)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n[![Docs](https://docs.rs/memcache/badge.svg)](https://docs.rs/memcache/)\n\nrust-memcache is a [memcached](https://memcached.org/) client written in pure rust.\n\n![logo](https://cloudflare-ipfs.com/ipfs/QmY2otmZFbrLfCQZ2JG8bsEsMGegHrh8WgupcyTcyoShiS)\n\n## Install\n\nThe crate is called `memcache` and you can depend on it via cargo:\n\n```ini\n[dependencies]\nmemcache = \"*\"\n```\n\n## Features\n\n- [x] All memcached supported protocols\n  - [x] Binary protocol\n  - [x] ASCII protocol\n- [x] All memcached supported connections\n  - [x] TCP connection\n  - [x] UDP connection\n  - [x] UNIX Domain socket connection\n  - [x] TLS connection\n- [ ] Encodings\n  - [x] Typed interface\n  - [ ] Automatically compress\n  - [ ] Automatically serialize to JSON / msgpack etc\n- [x] Memcached cluster support with custom key hash algorithm\n- [x] Authority\n  - [x] Binary protocol (plain SASL authority plain)\n  - [x] ASCII protocol\n\n## Basic usage\n\n```rust\n// create connection with to memcached server node:\nlet client = memcache::connect(\"memcache://127.0.0.1:12345?timeout=10\u0026tcp_nodelay=true\").unwrap();\n\n// flush the database\nclient.flush().unwrap();\n\n// set a string value\nclient.set(\"foo\", \"bar\", 0).unwrap();\n\n// retrieve from memcached:\nlet value: Option\u003cString\u003e = client.get(\"foo\").unwrap();\nassert_eq!(value, Some(String::from(\"bar\")));\nassert_eq!(value.unwrap(), \"bar\");\n\n// prepend, append:\nclient.prepend(\"foo\", \"foo\").unwrap();\nclient.append(\"foo\", \"baz\").unwrap();\nlet value: String = client.get(\"foo\").unwrap().unwrap();\nassert_eq!(value, \"foobarbaz\");\n\n// cas(check and set):\nlet (_, _, cas_token) = client.get(\"foo\").unwrap().unwrap();\nlet cas_id = cas_id.unwrap();\nclient.cas(\"foo\", \"qux\", 0, cas_id).unwrap();\n\n// delete value:\nclient.delete(\"foo\").unwrap();\n\n// using counter:\nclient.set(\"counter\", 40, 0).unwrap();\nclient.increment(\"counter\", 2).unwrap();\nlet answer: i32 = client.get(\"counter\").unwrap().unwrap();\nassert_eq!(answer, 42);\n```\n\n## Custom key hash function\n\nIf you have multiple memcached server, you can create the `memcache::Client` struct with a vector of urls of them. Which server will be used to store and retrive is based on what the key is.\n\nThis library have a basic rule to do this with rust's builtin hash function, and also you can use your custom function to do this, for something like you can using a have more data on one server which have more memory quota, or cluster keys with their prefix, or using consitent hash for large memcached cluster.\n\n```rust\nlet mut client = memcache::connect(vec![\"memcache://127.0.0.1:12345\", \"memcache:///tmp/memcached.sock\"]).unwrap();\nclient.hash_function = |key: \u0026str| -\u003e u64 {\n    // your custom hashing function here\n    return 1;\n};\n```\n\n## Contributing\n\nBefore sending pull request, please ensure:\n\n- `cargo fmt` is being run;\n- Commit message is using [gitmoji](https://gitmoji.carloscuesta.me/) with first character is lower cased, for example: `:sparkles: rust-memcache can print money now`.\n\n## Contributors\n\n\u003ca href=\"https://github.com/aisk/rust-memcache/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contributors-img.firebaseapp.com/image?repo=aisk/rust-memcache\" /\u003e\n\u003c/a\u003e\n\n## License\n\nMIT\n","funding_links":[],"categories":["Libraries","库 Libraries","库","\u003ca name=\"Rust\"\u003e\u003c/a\u003eRust"],"sub_categories":["Caching","缓存 Caching","高速缓存"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faisk%2Frust-memcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faisk%2Frust-memcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faisk%2Frust-memcache/lists"}