{"id":499,"library":"google-cloud-redis","title":"Google Cloud Redis","description":"Google Cloud Redis (also known as Memorystore for Redis) is a fully managed Redis service on Google Cloud Platform. This Python client library allows developers to programmatically create, manage, and interact with Redis instances, supporting operations like instance creation, deletion, and listing. The library is actively maintained by Google and receives frequent updates, typically aligning with broader Google Cloud client library releases.","status":"active","version":"2.21.0","language":"python","source_language":"en","source_url":"https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-redis","tags":["google cloud","redis","memorystore","database","managed service","client library"],"install":[{"cmd":"pip install google-cloud-redis","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"CloudRedisClient","correct":"from google.cloud import redis_v1"}],"quickstart":{"code":"import os\nfrom google.cloud import redis_v1\n\n# Your Google Cloud Project ID\nproject_id = os.environ.get('GOOGLE_CLOUD_PROJECT', 'your-project-id')\n# The region where you want to list instances, e.g., 'us-central1'\nlocation = 'global' # Or a specific region like 'us-central1'\n\ndef list_redis_instances(project_id: str, location: str):\n    \"\"\"Lists all Redis instances in a given project and location.\"\"\"\n    client = redis_v1.CloudRedisClient()\n    parent = f\"projects/{project_id}/locations/{location}\"\n\n    try:\n        # The `list_instances` method returns an iterable of Instance objects.\n        instances = client.list_instances(parent=parent)\n\n        if not instances:\n            print(f\"No Redis instances found in {location} for project {project_id}.\")\n            return\n\n        print(f\"Redis instances in {location} for project {project_id}:\")\n        for instance in instances:\n            print(f\"  Name: {instance.name}\")\n            print(f\"  Host: {instance.host}\")\n            print(f\"  Port: {instance.port}\")\n            print(f\"  State: {instance.state.name}\")\n            print(f\"  Tier: {instance.tier.name}\")\n            print(f\"  Memory size (GB): {instance.memory_size_gb}\")\n            print(\"  ---\")\n\n    except Exception as e:\n        print(f\"Error listing Redis instances: {e}\")\n\nif __name__ == \"__main__\":\n    # Set GOOGLE_CLOUD_PROJECT environment variable or replace 'your-project-id'\n    # Ensure GOOGLE_APPLICATION_CREDENTIALS is set up for authentication\n    list_redis_instances(project_id, location)\n","lang":"python","description":"This quickstart demonstrates how to initialize the Google Cloud Redis client and list existing Redis instances within a specified Google Cloud project and location. For authentication, ensure `GOOGLE_APPLICATION_CREDENTIALS` is set up (e.g., pointing to a service account key file, or rely on Application Default Credentials)."},"warnings":[{"fix":"Configure Serverless VPC Access for serverless environments (Cloud Functions, App Engine Standard) or VPC Network Peering for VM-based applications. Ensure client applications are deployed in the same region and VPC as the Redis instance, or have appropriate network connectivity configured.","message":"Connecting to a Memorystore for Redis instance from your application typically requires setting up Serverless VPC Access or VPC Network Peering. Direct public IP access is not usually available, and applications must be within the same VPC network or connected via a connector to access the Redis instance. Ensure your application's region aligns with your Redis instance's region for optimal connectivity and performance.","severity":"gotcha","affected_versions":"All"},{"fix":"Install `redis` (or `redis-py`) using `pip install redis` to perform data operations. Use the host, port, and optional AUTH string obtained from the `google-cloud-redis` client to connect `redis-py`.","message":"This library (`google-cloud-redis`) is for *managing* Google Cloud Redis instances (creating, listing, deleting). To *interact with data* in a Redis instance (e.g., `GET`, `SET`, `HSET`), you need a separate Redis client library like `redis-py`.","severity":"gotcha","affected_versions":"All"},{"fix":"Review the official release notes and migration guides for the specific major version you are upgrading to. Test your application thoroughly in a staging environment before deploying to production.","message":"Google Cloud client libraries sometimes introduce breaking changes in major version releases. Always consult the changelog and release notes on the official GitHub repository or Google Cloud documentation when upgrading across major versions to understand API changes, parameter shifts, or behavioral modifications.","severity":"breaking","affected_versions":"Across major versions (e.g., from 1.x.x to 2.x.x)"},{"fix":"When creating or updating an instance, enable AUTH and transit encryption. Retrieve the AUTH string via `gcloud redis instances get-auth-string` or the client library, and configure your `redis-py` client (or equivalent) to use this password and TLS when connecting. Ensure your client library supports TLS.","message":"Enabling Redis AUTH for your Memorystore instance provides an authentication token (UUID) for client connections. This enhances security but requires clients to explicitly authenticate. Furthermore, enabling in-transit encryption (TLS) is a critical best practice for securing data communication between your application and the Redis instance.","severity":"gotcha","affected_versions":"All"},{"fix":"Always handle the `Operation` object returned by methods like `create_instance` or `update_instance`. Use `operation.result()` for synchronous waiting or `operation.add_done_callback()` for asynchronous handling to ensure the operation has finished successfully or to catch errors.","message":"Many Google Cloud operations, particularly instance creation or updates, are long-running operations (LROs). The client library returns an `Operation` object. You must explicitly call `.result()` on this object to wait for the operation to complete and retrieve its final status or result, or handle it asynchronously.","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure your environment is correctly authenticated. For local development, run `gcloud auth application-default login`. For production environments, use service accounts attached to your compute resources (e.g., GKE, Cloud Run, Compute Engine) or provide service account credentials via the `GOOGLE_APPLICATION_CREDENTIALS` environment variable if running outside managed Google Cloud services.","message":"The Google Cloud client libraries require proper authentication to make API calls. The `DefaultCredentialsError` indicates that the application could not find Application Default Credentials (ADC). This is a common issue when running applications locally without `gcloud auth application-default login` or in environments (like Docker containers) without service account keys or ADC configured via environment variables (e.g., `GOOGLE_APPLICATION_CREDENTIALS`).","severity":"breaking","affected_versions":"All"},{"fix":"Ensure proper authentication is configured for your environment. For local development, run `gcloud auth application-default login`. For deployed applications, configure a service account, enable Workload Identity, or ensure the underlying compute resource (e.g., GCE VM, Cloud Run, Cloud Functions) has the necessary IAM permissions and scopes.","message":"The `google-cloud-redis` client library (and most Google Cloud client libraries) requires authentication to interact with Google Cloud services. This error indicates that Application Default Credentials (ADC) or other authentication methods were not found, preventing the client from initializing and making API calls.","severity":"breaking","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-05-12T14:23:30.091Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Ensure the library is installed using pip: `pip install google-cloud-redis`","cause":"The `google-cloud-redis` Python client library, or its specific API version module `redis_v1`, is not installed or not accessible in the current Python environment.","error":"ModuleNotFoundError: No module named 'google.cloud.redis_v1'"},{"fix":"Grant the required IAM roles (e.g., `roles/redis.admin`, `roles/owner`) to the service account or user interacting with the Memorystore for Redis API.","cause":"The authenticated Google Cloud identity (user or service account) lacks the necessary IAM permissions to perform the requested operation on the Redis instance or project.","error":"google.api_core.exceptions.PermissionDenied: 403 Permission denied"},{"fix":"Choose a different, unallocated IP address range for your Redis instance, ensure the VPC network peering is correctly established, or let Memorystore automatically allocate a range.","cause":"During Redis instance creation, the specified IP address range for private services access conflicts with an existing allocated range in your VPC network, or the network peering is misconfigured.","error":"google.api_core.exceptions.InvalidArgument: 400 The IP address range ... is already in use"},{"fix":"Verify the Redis instance ID, project ID, and region/zone are correct, and ensure the instance actually exists in Google Cloud Memorystore for Redis.","cause":"The Redis instance you are trying to access, update, or delete does not exist or its name/location is incorrect.","error":"google.api_core.exceptions.NotFound: 404 Not found"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.69,"mem_mb":24.1,"disk_size":"68.2M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.99,"mem_mb":20.9,"disk_size":"66M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.42,"mem_mb":26.1,"disk_size":"72.9M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.74,"mem_mb":23.1,"disk_size":"71M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.49,"mem_mb":26,"disk_size":"64.3M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.93,"mem_mb":22.4,"disk_size":"62M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":2.37,"mem_mb":26.4,"disk_size":"63.9M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.96,"mem_mb":23.3,"disk_size":"62M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.54,"mem_mb":23.9,"disk_size":"68.3M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":1.19,"mem_mb":20.7,"disk_size":"66M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}