{"id":19374826,"url":"https://github.com/malwarebo/memcachex","last_synced_at":"2025-06-26T01:03:22.037Z","repository":{"id":188846557,"uuid":"679195971","full_name":"malwarebo/memcachex","owner":"malwarebo","description":"Implementation of libmemached.","archived":false,"fork":false,"pushed_at":"2025-04-01T10:27:15.000Z","size":1396,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T11:29:42.537Z","etag":null,"topics":["cpp","libmemcached","memcached"],"latest_commit_sha":null,"homepage":"","language":"C++","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/malwarebo.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-08-16T09:58:26.000Z","updated_at":"2025-04-01T10:27:21.000Z","dependencies_parsed_at":"2024-07-21T15:23:11.480Z","dependency_job_id":null,"html_url":"https://github.com/malwarebo/memcachex","commit_stats":null,"previous_names":["malwarebo/memcachex","kbww/memcachex"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/malwarebo/memcachex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malwarebo%2Fmemcachex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malwarebo%2Fmemcachex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malwarebo%2Fmemcachex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malwarebo%2Fmemcachex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/malwarebo","download_url":"https://codeload.github.com/malwarebo/memcachex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malwarebo%2Fmemcachex/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261978909,"owners_count":23239417,"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":["cpp","libmemcached","memcached"],"created_at":"2024-11-10T08:36:13.519Z","updated_at":"2025-06-26T01:03:21.989Z","avatar_url":"https://github.com/malwarebo.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# memcachex\n\nA C++ wrapper library for memcached using the libmemcached library.\n\n## Overview\n\nmemcachex provides a simple, modern C++ interface to interact with memcached servers. It uses libmemcached under the hood and offers a cleanerAPI for common memcached operations.\n\n## Requirements\n\n- C++11 compatible compiler\n- CMake 3.29.3 or higher\n- libmemcached 1.0.18 or higher\n- macOS (tested on arm64 architecture) or Linux\n\n## Building\n\n### macOS (with Homebrew)\n\n1. Install the dependencies:\n\n```bash\nbrew install cmake libmemcached\n```\n\n2. Create a build directory, configure the project, and compile:\n\n```bash\nmkdir -p build \u0026\u0026 cd build\ncmake ..\nmake\n```\n\n## Example Usage\n\n```cpp\n#include \"MemcachedClient.h\"\n#include \u003ciostream\u003e\n\nint main() {\n   // Initialize client with default server (localhost:11211)\n   memcachex::MemcachedClient client;\n   \n   // Or with specific server config\n   memcachex::ServerConfig config;\n   config.host = \"localhost\";\n   config.port = 11211;\n   memcachex::MemcachedClient client2(config);\n   \n   // Set a value\n   if (client.set(\"my_key\", \"my_value\")) {\n      std::cout \u003c\u003c \"Successfully set key\" \u003c\u003c std::endl;\n   }\n   \n   // Get a value\n   std::string value = client.get(\"my_key\");\n   if (!value.empty()) {\n      std::cout \u003c\u003c \"Retrieved value: \" \u003c\u003c value \u003c\u003c std::endl;\n   }\n   \n   // Delete a key\n   if (client.remove(\"my_key\")) {\n      std::cout \u003c\u003c \"Successfully deleted key\" \u003c\u003c std::endl;\n   }\n   \n   return 0;\n}\n```\n\n## Constructor Options\n\nThe `MemcachedClient` class provides the following constructors:\n\n```cpp\n// Default constructor - no servers configured\nMemcachedClient();\n\n// Constructor with a single server config\nMemcachedClient(const ServerConfig\u0026 config);\n\n// Constructor with multiple server configs\nMemcachedClient(const std::vector\u003cServerConfig\u003e\u0026 configs);\n```\n\nThe `ServerConfig` struct allows you to specify server details:\n\n```cpp\nstruct ServerConfig {\n    std::string host = \"localhost\";\n    uint16_t port = 11211;\n    uint32_t weight = 1;\n};\n```\n\n## Methods\n\n### Basic Operations\n\n- `bool set(const std::string\u0026 key, const std::string\u0026 value, time_t expiration = 0)`: Store a value with the given key\n- `std::string get(const std::string\u0026 key)`: Retrieve a value for the given key\n- `bool remove(const std::string\u0026 key, time_t expiration = 0)`: Delete a key-value pair\n\n### Additional Operations\n\n- `bool add(const std::string\u0026 key, const std::string\u0026 value, time_t expiration = 0)`: Add a new key-value only if it doesn't exist\n- `bool replace(const std::string\u0026 key, const std::string\u0026 value, time_t expiration = 0)`: Replace existing key-value\n- `bool append(const std::string\u0026 key, const std::string\u0026 value)`: Append to an existing value\n- `bool prepend(const std::string\u0026 key, const std::string\u0026 value)`: Prepend to an existing value\n- `uint64_t increment(const std::string\u0026 key, uint32_t offset = 1)`: Increment numeric value\n\n### Error Handling\n\n- `std::string getLastErrorMessage() const`: Get the last error message\n- `memcached_return_t getLastReturnCode() const`: Get the last return code\n- `void throwIfError(memcached_return_t rc, const std::string\u0026 operation) const`: Throw a MemcachedError exception if operation failed\n\n## Exception Handling\n\nThe library provides a `MemcachedError` exception class that can be caught to handle errors:\n\n```cpp\ntry {\n    client.throwIfError(rc, \"operation\");\n} catch (const memcachex::MemcachedError\u0026 e) {\n    std::cerr \u003c\u003c e.what() \u003c\u003c std::endl;\n    auto code = e.getReturnCode(); // Get the return code\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalwarebo%2Fmemcachex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmalwarebo%2Fmemcachex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalwarebo%2Fmemcachex/lists"}