[Yandex Cloud documentation](../../index.md) > [Yandex Managed Service for Valkey™](../index.md) > [Step-by-step guides](index.md) > Clusters > Working with Valkey™ models

# Working with Valkey™ modules

In Yandex Managed Service for Valkey™, you can use [modules](../concepts/modules.md) (Valkey™ kernel extensions). Modules provide functionality to address modern-day needs through the use of high-load services and AI platforms: vector search, efficiently stored JSON data structures, and scalable probability filters.

You can connect modules to a [new](cluster-create.md) or [existing](#enable-modules) cluster or [reconfigure a module](#change-modules).

## Connecting modules {#enable-modules}

{% note warning %}

You cannot disable modules once enabled.

{% endnote %}

{% list tabs group=instructions %}

- Management console {#console}

    1. In the [management console](https://console.yandex.cloud), select the folder containing your cluster.
    1. Navigate to **Yandex Managed Service for&nbsp;Valkey™**.
    1. Select the cluster.
    1. At the top of the page, click **Edit**.
    1. Under **Modules**, enable the required Valkey™ modules.

        For the **Search** module, configure the following: **Number of reader threads** and **Number of writer threads**.

    1. Click **Save changes**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To connect modules:

  1. View the description of the CLI command for updating a cluster:

     ```bash
     yc managed-redis cluster update --help
     ```

  1. Run this command to connect modules:

     ```bash
     yc managed-redis cluster update \
       --cluster-name=<cluster_name> \
       --valkey-modules enable-valkey-search=<enable_Valkey-Search_module>,`
                        `valkey-search-reader-threads=<number_of_request_processing_threads>,`
                        `valkey-search-writer-threads=<number_of_indexing_threads>,`
                        `enable-valkey-json=<enable_Valkey-JSON_module>,`
                        `enable-valkey-bloom=<enable_Valkey-Bloom_module>
     ```

     Where:
     * `--cluster-name`: Yandex Managed Service for Valkey™ cluster name. You can get it from the [list of clusters in the folder](cluster-list.md#list-clusters).
     * `--valkey-modules`: [Valkey™ module](../concepts/modules.md) parameters:
        * `enable-valkey-search`: Enable the `Valkey-Search` module, `true` or `false`.
        * `valkey-search-reader-threads`: Number of request processing threads in the `Valkey-Search` module.
        * `valkey-search-writer-threads`: Number of indexing threads in the `Valkey-Search` module.
        * `enable-valkey-json`: Enable the `Valkey-JSON` module, `true` or `false`.
        * `enable-valkey-bloom`: Enable the `Valkey-Bloom` module, `true` or `false`.

- Terraform {#tf}

    1. Open the current Terraform configuration file with the infrastructure plan.

        For information on how to create this file, see [Creating a cluster](cluster-create.md).

    1. Add the `modules` section to the Yandex Managed Service for Valkey™ cluster description:

        ```hcl
        resource "yandex_mdb_redis_cluster_v2" "<cluster_name>" {
          ...
          modules = {
            valkey_bloom = {
              enabled = <enable_Valkey-Bloom_module>
            }
            valkey_json = {
              enabled = <enable_Valkey-JSON_module>
            }
            valkey_search = {
              enabled        = <enable_Valkey-Search_module>
              reader_threads = <number_of_request_processing_threads>
              writer_threads = <number_of_indexing_threads>
            }
          }
        }
        ```

        Where:

        * `valkey_bloom.enabled`: Enable the `Valkey-Bloom` module, `true` or `false`.
        * `valkey_json.enabled`: Enable the `Valkey-JSON` module, `true` or `false`.
        * `valkey_search.enabled`: Enable the `Valkey-Search` module, `true` or `false`.
        * `valkey_search.reader_threads`: Number of request processing threads in the `Valkey-Search` module.
        * `valkey_search.writer_threads`: Number of indexing threads in the `Valkey-Search` module.

    1. Make sure the settings are correct.

        1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
        1. Run this command:
        
           ```bash
           terraform validate
           ```
        
           Terraform will show any errors found in your configuration files.

    1. Confirm updating the resources.

        1. Run this command to view the planned changes:
        
           ```bash
           terraform plan
           ```
        
           If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
        
        1. If everything looks correct, apply the changes:
           1. Run this command:
        
              ```bash
              terraform apply
              ```
        
           1. Confirm updating the resources.
           1. Wait for the operation to complete.

    For more information, see [this Terraform provider guide](../../terraform/resources/mdb_redis_cluster_v2.md).

    {% note warning "Timeouts" %}
    
    The Terraform provider sets the following timeouts for Yandex Managed Service for Valkey™ cluster operations:
    
    * Creating a cluster, including by restoring it from a backup: 15 minutes.
    * Editing a cluster: 60 minutes.
    * Deleting a cluster: 15 minutes.
    
    Operations exceeding the timeout are aborted.
    
    {% cut "How do I change these limits?" %}
    
    Add the `timeouts` section to your cluster description, such as the following:
    
    ```hcl
    resource "yandex_mdb_redis_cluster_v2" "<cluster_name>" {
      ...
      timeouts = {
        create = "1h30m" # 1 hour 30 minutes
        update = "2h"    # 2 hours
        delete = "30m"   # 30 minutes
      }
    }
    ```
    
    {% endcut %}
    
    {% endnote %}

- REST API {#api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Call the [Cluster.Update](../api-ref/Cluster/update.md) method, e.g., via the following [cURL](https://curl.se/) request:

        {% note warning %}
        
        The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `updateMask` parameter as a single comma-separated string.
        
        {% endnote %}

        ```bash
        curl \
            --request PATCH \
            --header "Authorization: Bearer $IAM_TOKEN" \
            --header "Content-Type: application/json" \
            --url 'https://mdb.api.cloud.yandex.net/managed-redis/v1/clusters/<cluster_ID>' \
            --data '{
                      "updateMask": "configSpec.modules.valkeySearch.enabled,configSpec.modules.valkeySearch.readerThreads,configSpec.modules.valkeySearch.writerThreads,configSpec.valkeyJson.enabled,configSpec.valkeyBloom.enabled",
                      "configSpec": {
                        "modules": {
                          "valkeySearch": {
                            "enabled": "<enable_Valkey-Search_module>",
                            "readerThreads": "<number_of_request_processing_threads>",
                            "writerThreads": "<number_of_indexing_threads>"
                          },
                          "valkeyJson": {
                            "enabled": "<enable_Valkey-JSON_module>"
                          },
                          "valkeyBloom": {
                            "enabled": "<enable_Valkey-Bloom_module>"
                          }
                        }
                      }
                    }'
        ```

        Where:

        * `updateMask`: Comma-separated string of settings to update.

        * `configSpec.modules`: Valkey™ module parameters:

            * `valkeySearch.enabled`: Enable the `Valkey-Search` module, `true` or `false`. What you can set up for the module:
                * `valkeySearch.readerThreads`: Number of request processing threads.
                * `valkeySearch.writerThreads`: Number of indexing threads.
            * `valkeyJson.enabled`: Enable the `Valkey-JSON` module, `true` or `false`.
            * `valkeyBloom.enabled`: Enable the `Valkey-Bloom` module, `true` or `false`.

        You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

    1. Check the [server response](../api-ref/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
       
       ```bash
       cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
       ```
       
       Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

    1. Call the [ClusterService.Update](../api-ref/grpc/Cluster/update.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

        {% note warning %}
        
        The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `update_mask` parameter as an array of `paths[]` strings.
        
        {% cut "Format for listing settings" %}
        
        ```yaml
        "update_mask": {
            "paths": [
                "<setting_1>",
                "<setting_2>",
                ...
                "<setting_N>"
            ]
        }
        ```
        
        {% endcut %}
        
        {% endnote %}

        ```bash
        grpcurl \
            -format json \
            -import-path ~/cloudapi/ \
            -import-path ~/cloudapi/third_party/googleapis/ \
            -proto ~/cloudapi/yandex/cloud/mdb/redis/v1/cluster_service.proto \
            -rpc-header "Authorization: Bearer $IAM_TOKEN" \
            -d '{
                  "cluster_id": "<cluster_ID>",
                  "update_mask": {
                    "paths": [
                      "config_spec.modules.valkey_search.enabled",
                      "config_spec.modules.valkey_search.reader_threads",
                      "config_spec.modules.valkey_search.writer_threads",
                      "config_spec.valkey_json.enabled",
                      "config_spec.valkey_bloom.enabled"
                    ]
                  },
                  "config_spec": {
                    "modules": {
                      "valkey_search": {
                        "enabled": "<enable_Valkey-Search_module>",
                        "reader_threads": "<number_of_request_processing_threads>",
                        "writer_threads": "<number_of_indexing_threads>"
                      },
                      "valkey_json": {
                        "enabled": "<enable_Valkey-JSON_module>"
                      },
                      "valkey_bloom": {
                        "enabled": "<enable_Valkey-Bloom_module>"
                      }
                    }
                  }
                }' \
            mdb.api.cloud.yandex.net:443 \
            yandex.cloud.mdb.redis.v1.ClusterService.Update
        ```

        Where:

        * `update_mask`: List of settings to update as an array of strings (`paths[]`).

        * `config_spec.modules`: Valkey™ module parameters:

            * `valkey_search.enabled`: Enable the `Valkey-Search` module, `true` or `false`. What you can set up for the module:
                * `valkey_search.reader_threads`: Number of request processing threads.
                * `valkey_search.writer_threads`: Number of indexing threads.
            * `valkey_json.enabled`: Enable the `Valkey-JSON` module, `true` or `false`.
            * `valkey_bloom.enabled`: Enable the `Valkey-Bloom` module, `true` or `false`.

        You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

    1. Check the [server response](../api-ref/grpc/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}

## Updating module settings {#change-modules}

{% list tabs group=instructions %}

- Management console {#console}

    1. In the [management console](https://console.yandex.cloud), select the folder containing your cluster.
    1. Navigate to **Yandex Managed Service for&nbsp;Valkey™**.
    1. Select the cluster.
    1. At the top of the page, click **Edit**.
    1. Under **Modules**, edit the Valkey™ module settings.

        You can set up the following for the **Search** module:

        * **Number of reader threads**.
        * **Number of writer threads**.

    1. Click **Save changes**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To update module settings:

  1. View the description of the CLI command for updating a cluster:

     ```bash
     yc managed-redis cluster update --help
     ```

  1. Run this command to update module settings:

     ```bash
     yc managed-redis cluster update \
       --cluster-name=<cluster_name> \
       --valkey-modules valkey-search-reader-threads=<number_of_request_processing_threads>,`
                        `valkey-search-writer-threads=<number_of_indexing_threads>
     ```

     Where:
     * `--cluster-name`: Yandex Managed Service for Valkey™ cluster name. You can get it from the [list of clusters in the folder](cluster-list.md#list-clusters).
     * `--valkey-modules`: [Valkey™ module](../concepts/modules.md) parameters:
        * `valkey-search-reader-threads`: Number of request processing threads in the `Valkey-Search` module.
        * `valkey-search-writer-threads`: Number of indexing threads in the `Valkey-Search` module.

- Terraform {#tf}

    1. Open the current Terraform configuration file with the infrastructure plan.

       For information on how to create this file, see [Creating a cluster](cluster-create.md).

    1. In the Yandex Managed Service for Valkey™ cluster description, do the necessary editing under `modules.valkey_search`:

        ```hcl
        resource "yandex_mdb_redis_cluster_v2" "<cluster_name>" {
          ...
          modules = {
            ...
            valkey_search = {
              ...
              reader_threads = <number_of_request_processing_threads>
              writer_threads = <number_of_indexing_threads>
            }
          }
        }
        ```

        Where:

        * `reader_threads`: Number of request processing threads in the `Valkey-Search` module.
        * `writer_threads`: Number of indexing threads in the `Valkey-Search` module.

    1. Make sure the settings are correct.

       1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
       1. Run this command:
       
          ```bash
          terraform validate
          ```
       
          Terraform will show any errors found in your configuration files.

    1. Confirm updating the resources.

       1. Run this command to view the planned changes:
       
          ```bash
          terraform plan
          ```
       
          If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
       
       1. If everything looks correct, apply the changes:
          1. Run this command:
       
             ```bash
             terraform apply
             ```
       
          1. Confirm updating the resources.
          1. Wait for the operation to complete.

    For more information, see [this Terraform provider guide](../../terraform/resources/mdb_redis_cluster_v2.md).

    {% note warning "Timeouts" %}
    
    The Terraform provider sets the following timeouts for Yandex Managed Service for Valkey™ cluster operations:
    
    * Creating a cluster, including by restoring it from a backup: 15 minutes.
    * Editing a cluster: 60 minutes.
    * Deleting a cluster: 15 minutes.
    
    Operations exceeding the timeout are aborted.
    
    {% cut "How do I change these limits?" %}
    
    Add the `timeouts` section to your cluster description, such as the following:
    
    ```hcl
    resource "yandex_mdb_redis_cluster_v2" "<cluster_name>" {
      ...
      timeouts = {
        create = "1h30m" # 1 hour 30 minutes
        update = "2h"    # 2 hours
        delete = "30m"   # 30 minutes
      }
    }
    ```
    
    {% endcut %}
    
    {% endnote %}

- REST API {#api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Call the [Cluster.Update](../api-ref/Cluster/update.md) method, e.g., via the following [cURL](https://curl.se/) request:

        {% note warning %}
        
        The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `updateMask` parameter as a single comma-separated string.
        
        {% endnote %}

        ```bash
        curl \
            --request PATCH \
            --header "Authorization: Bearer $IAM_TOKEN" \
            --header "Content-Type: application/json" \
            --url 'https://mdb.api.cloud.yandex.net/managed-redis/v1/clusters/<cluster_ID>' \
            --data '{
                      "updateMask": "configSpec.modules.valkeySearch.readerThreads,configSpec.modules.valkeySearch.writerThreads",
                      "configSpec": {
                        "modules": {
                          "valkeySearch": {
                            "readerThreads": "<number_of_request_processing_threads>",
                            "writerThreads": "<number_of_indexing_threads>"
                          }
                        }
                      }
                    }'
        ```

        Where:

        * `updateMask`: Comma-separated string of settings to update.

        * `configSpec.modules`: Valkey™ module parameters:

            * `valkeySearch.readerThreads`: Number of request processing threads in the `Valkey-Search` module.
            * `valkeySearch.writerThreads`: Number of indexing threads in the `Valkey-Search` module.

        You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

    1. Check the [server response](../api-ref/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

    1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
       
       ```bash
       cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
       ```
       
       Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

    1. Call the [ClusterService.Update](../api-ref/grpc/Cluster/update.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

        {% note warning %}
        
        The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `update_mask` parameter as an array of `paths[]` strings.
        
        {% cut "Format for listing settings" %}
        
        ```yaml
        "update_mask": {
            "paths": [
                "<setting_1>",
                "<setting_2>",
                ...
                "<setting_N>"
            ]
        }
        ```
        
        {% endcut %}
        
        {% endnote %}

        ```bash
        grpcurl \
            -format json \
            -import-path ~/cloudapi/ \
            -import-path ~/cloudapi/third_party/googleapis/ \
            -proto ~/cloudapi/yandex/cloud/mdb/redis/v1/cluster_service.proto \
            -rpc-header "Authorization: Bearer $IAM_TOKEN" \
            -d '{
                  "cluster_id": "<cluster_ID>",
                  "update_mask": {
                    "paths": [
                      "config_spec.modules.valkey_search.reader_threads",
                      "config_spec.modules.valkey_search.writer_threads"
                    ]
                  },
                  "modules": {
                    "valkey_search": {
                      "reader_threads": "<number_of_request_processing_threads>",
                      "writer_threads": "<number_of_indexing_threads>"
                    }
                  }
                }' \
            mdb.api.cloud.yandex.net:443 \
            yandex.cloud.mdb.redis.v1.ClusterService.Update
        ```

        Where:

        * `update_mask`: List of parameters to update as an array of strings (`paths[]`).

        * `config_spec.modules`: Valkey™ module parameters:

            * `valkey_search.reader_threads`: Number of request processing threads in the `Valkey-Search` module.
            * `valkey_search.writer_threads`: Number of indexing threads in the `Valkey-Search` module.

        You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

    1. Check the [server response](../api-ref/grpc/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}