Google Cloud Memorystore Memcached Operators

The Cloud Memorystore for Memcached is a fully managed Memcached service for Google Cloud. Applications running on Google Cloud can achieve extreme performance by leveraging the highly scalable, available, secure Memcached service without the burden of managing complex Memcached deployments.

Prerequisite Tasks

To use these operators, you must do a few things:

Instance

Operators uses a Instance for representing instance. The object can be presented as a compatible dictionary also.

Here is an example of instance

tests/system/providers/google/cloud/cloud_memorystore/example_cloud_memorystore_memcached.py[source]

MEMCACHED_INSTANCE = {
    "name": "",
    "node_count": 1,
    "node_config": {"cpu_count": 1, "memory_size_mb": 1024},
    "zones": [LOCATION + "-a"],
}

Create instance

Create a instance is performed with the CloudMemorystoreMemcachedCreateInstanceOperator operator.

tests/system/providers/google/cloud/cloud_memorystore/example_cloud_memorystore_memcached.py[source]

create_memcached_instance = CloudMemorystoreMemcachedCreateInstanceOperator(
    task_id="create-instance",
    location=LOCATION,
    instance_id=MEMORYSTORE_MEMCACHED_INSTANCE_NAME,
    instance=MEMCACHED_INSTANCE,
    project_id=PROJECT_ID,
)

Delete instance

Delete an instance is performed with the CloudMemorystoreMemcachedDeleteInstanceOperator operator.

tests/system/providers/google/cloud/cloud_memorystore/example_cloud_memorystore_memcached.py[source]

delete_memcached_instance = CloudMemorystoreMemcachedDeleteInstanceOperator(
    task_id="delete-instance",
    location=LOCATION,
    instance=MEMORYSTORE_MEMCACHED_INSTANCE_NAME,
    project_id=PROJECT_ID,
)

Get instance

Get an instance is performed with the CloudMemorystoreMemcachedGetInstanceOperator operator.

tests/system/providers/google/cloud/cloud_memorystore/example_cloud_memorystore_memcached.py[source]

get_memcached_instance = CloudMemorystoreMemcachedGetInstanceOperator(
    task_id="get-instance",
    location=LOCATION,
    instance=MEMORYSTORE_MEMCACHED_INSTANCE_NAME,
    project_id=PROJECT_ID,
)

List instances

List instances is performed with the CloudMemorystoreMemcachedListInstancesOperator operator.

tests/system/providers/google/cloud/cloud_memorystore/example_cloud_memorystore_memcached.py[source]

list_memcached_instances = CloudMemorystoreMemcachedListInstancesOperator(
    task_id="list-instances", location="-", project_id=PROJECT_ID
)

Update instance

Updating an instance is performed with the CloudMemorystoreMemcachedUpdateInstanceOperator operator.

tests/system/providers/google/cloud/cloud_memorystore/example_cloud_memorystore_memcached.py[source]

update_memcached_instance = CloudMemorystoreMemcachedUpdateInstanceOperator(
    task_id="update-instance",
    location=LOCATION,
    instance_id=MEMORYSTORE_MEMCACHED_INSTANCE_NAME,
    project_id=PROJECT_ID,
    update_mask=FieldMask(paths=["node_count"]),
    instance={"node_count": 2},  # 2
)

Update and apply parameters to an instance

To update and apply Memcached parameters to an instance use CloudMemorystoreMemcachedUpdateParametersOperator and CloudMemorystoreMemcachedApplyParametersOperator operator.

tests/system/providers/google/cloud/cloud_memorystore/example_cloud_memorystore_memcached.py[source]

update_memcached_parameters = CloudMemorystoreMemcachedUpdateParametersOperator(
    task_id="update-parameters",
    location=LOCATION,
    instance_id=MEMORYSTORE_MEMCACHED_INSTANCE_NAME,
    project_id=PROJECT_ID,
    update_mask={"paths": ["params"]},
    parameters={"params": {"protocol": "ascii", "hash_algorithm": "jenkins"}},
)

apply_memcached_parameters = CloudMemorystoreMemcachedApplyParametersOperator(
    task_id="apply-parameters",
    location=LOCATION,
    instance_id=MEMORYSTORE_MEMCACHED_INSTANCE_NAME,
    project_id=PROJECT_ID,
    node_ids=["node-a-1"],
    apply_all=False,
)

Reference

For further information, look at:

Was this entry helpful?