{"library":"python-binary-memcached","title":"Python Binary Memcached Client","description":"A pure Python module for accessing Memcached servers using the binary protocol, including support for SASL authentication and TLS. The current version is 0.31.4, with releases occurring periodically to add features and improvements.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install python-binary-memcached","pip install python-binary-memcached[sasl]"],"cli":null},"imports":["from bmemcached import Client","from bmemcached import DistributedClient"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import bmemcached\nimport os\n\n# Configure client with Memcached server address, optional username, and password\n# Use environment variables for sensitive information\nservers = ['127.0.0.1:11211']\nusername = os.environ.get('MEMCACHED_USER', '')\npassword = os.environ.get('MEMCACHED_PASSWORD', '')\n\nmc = bmemcached.Client(servers, username, password)\n\n# Set a key-value pair\nmc.set('my_key', 'Hello, Memcached!')\nprint(f\"Set 'my_key': {mc.get('my_key')}\")\n\n# Get a key-value pair\nvalue = mc.get('my_key')\nif value:\n    print(f\"Retrieved 'my_key': {value.decode('utf-8')}\")\nelse:\n    print(\"'my_key' not found\")\n\n# Delete a key\nmc.delete('my_key')\nprint(f\"Deleted 'my_key'. Now 'my_key' is: {mc.get('my_key')}\")","lang":"python","description":"Initializes a `bmemcached.Client` instance, sets a string value, retrieves it, and then deletes it. Ensure a Memcached server is running at `127.0.0.1:11211`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}