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.
pip install google-cloud-redisVerified import paths — ran on the pinned version, not inferred.
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).
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.
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`.
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.
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.
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.
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.
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.
Ensure the library is installed using pip: `pip install google-cloud-redis`
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.
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.
Verify the Redis instance ID, project ID, and region/zone are correct, and ensure the instance actually exists in Google Cloud Memorystore for Redis.
No dependency data recorded yet.