> For the complete documentation index, see [llms.txt](https://academy.cegedim.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://academy.cegedim.cloud/databases/valkey/valkey-get-started.md).

# Valkey - Get started

## How to provision a Valkey PaaS? <a href="#valkeyhowtos-howtoprovisionavalkey" id="valkeyhowtos-howtoprovisionavalkey"></a>

To get started, go to ITCare and search for your target global service where you will create your new Valkey deployment.

Search for your Global Service in the top search bar and click on it to display its information page.

Once in your Global Service, click on the **Create Resource** button, select **Valkey** and the required version.

Fill out the form:

* Select a topology
* Define the name of the future deployment
* The sizing
* The storage required on each instance
* The target location
* The target network
* Management options (backup, monitoring, 24/7, remote site replication)

Click **Next** once the fields have been filled in.

At the customization stage:

* Enter the administrator account password that will be provided
* Select the required persistence options
* Enable or disable TLS encryption

Then click **Next**.

{% hint style="warning" %}
Passwords are not saved by cegedim.cloud.

Be sure to save your password!
{% endhint %}

Review the summary before submitting the form.

{% hint style="info" %}
Provisioning may take up to 2 hours depending on the current automation load.
{% endhint %}

Once the deployment is ready, you will be notified by email.

## How to connect to a standalone Valkey instance?

This code describes how to connect to Valkey when the topology is a single instance. This code is deliberately simplified (errors are not handled) and is intended for demonstration purposes only.

The Python language is used. We assume that the Valkey instance is named pcluvlk01.hosting.cegedim.cloud.

<details>

<summary>Python example without TLS</summary>

{% code overflow="wrap" lineNumbers="true" %}

```python
import valkey
 
def main():
    try:
        myValkey = valkey.Valkey(host=‘pcluvlk01.hosting.cegedim.cloud’, port=6379, db=0, password=‘1MyStrongPassword!’, username=‘valkey’, decode_responses=True)
        pong = myValkey.ping()
        print(pong) # should be True
        myValkey.set(‘mykey’,'myvalue')
        print(myValkey.get(‘mykey’)) # should be myvalue
        myValkey.close()
    except Exception as ex:
        print(ex)
 
if __name__ == “__main__”:
    main()
```

{% endcode %}

</details>

<details>

<summary>Python example with TLS</summary>

{% code overflow="wrap" lineNumbers="true" %}

```python
import valkey
 
def main():
    try:
        myValkey = valkey.Valkey(host=‘pcluvlk01.hosting.cegedim.cloud’, port=6379, db=0, password=‘1MyStrongPassword!’, username=‘valkey’, decode_responses=True)
        pong = myValkey.ping()
        print(pong) # should be True
        myValkey.set(‘mykey’,'myvalue')
        print(myValkey.get(‘mykey’)) # should be myvalue
        myValkey.close()
    except Exception as ex:
        print(ex)
 
if __name__ == “__main__”:
    main()
```

{% endcode %}

</details>

## How to connect to a Valkey cluster?

This code describes how to connect to Valkey when the topology is Cluster (with Sentinel). It has been deliberately simplified (errors are not handled) and is intended for demonstration purposes only.

The Python language is used.

We assume that the Valkey cluster is named **my-cluster** with a prefix **pclu**.\
There are therefore 3 machines:

* pcluvlk01.hosting.cegedim.cloud
* pcluvlk02.hosting.cegedim.cloud
* pcluvlk03.hosting.cegedim.cloud

Two examples are provided, with and without TLS.

<details>

<summary>Exemple Python sans TLS</summary>

{% code overflow="wrap" lineNumbers="true" %}

```python
from valkey.sentinel import Sentinel
import valkey
 
def main():
    try:
        mySentinel = Sentinel(
          [
            ('pcluvlk01.hosting.cegedim.cloud', 26379),
            ('pcluvlk02.hosting.cegedim.cloud', 26379),
            ('pcluvlk03.hosting.cegedim.cloud', 26379)
          ],
          sentinel_kwargs={
            'username': 'valkey',
            'password': '1MyStrongPassword!',
            'socket_connect_timeout': 0.5
          }
        )
         
        master_host, master_port = mySentinel.discover_master('my-cluster')
        print("Valkey master address: {}, TCP port {}".format(master_host, master_port))
        myMaster = valkey.Valkey(
          host=master_host,
          port=master_port,
          db=0,
          password='1MyStrongPassword!',
          username='valkey',
          decode_responses=True
        )
        pong = myMaster.ping()
        print(pong) # should be True
        myMaster.set('mykey','myvalue')
        print(myMaster.get('mykey')) # should be myvalue
        myMaster.close()
        replicas = mySentinel.discover_slaves('my-cluster')
        for replica in replicas:
            replica_host = replica[0]
            replica_port = replica[1]
            myReplica = valkey.Valkey(host=replica_host, port=replica_port, db=0, password='1MyStrongPassword!', username='valkey', decode_responses=True)
            print("replica address {} port {} mykey {}".format(replica_host, replica_port, myReplica.get('mykey'))) # should be myvalue
            myReplica.close()
         
    except Exception as ex:
        print(ex)
 
if __name__ == "__main__":
    main()
```

{% endcode %}

</details>

<details>

<summary>Exemple Python avec TLS</summary>

{% code overflow="wrap" lineNumbers="true" %}

```python
from valkey.sentinel import Sentinel
import valkey
 
def main():
    try:
        mySentinel = Sentinel(
          [
            ('pcluvlk01.hosting.cegedim.cloud', 26379),
            ('pcluvlk02.hosting.cegedim.cloud', 26379),
            ('pcluvlk03.hosting.cegedim.cloud', 26379)
          ],
          sentinel_kwargs={
            'username': 'valkey',
            'password': '1MyStrongPassword!',
            'ssl': True,
            'ssl_ca_certs': '/tmp/ca-valkey.crt',
            'ssl_cert_reqs': None,
            'ssl_certfile': None,
            'ssl_keyfile': None,
            'ssl_check_hostname': False,
            'socket_connect_timeout': 0.5
          }
        )
         
        master_host, master_port = mySentinel.discover_master('my-cluster')
        print("Valkey master address: {}, TCP port {}".format(master_host, master_port))
        myMaster = valkey.Valkey(
          host=master_host,
          port=master_port,
          db=0,
          password='1MyStrongPassword!',
          username='valkey',
          decode_responses=True,
          ssl=True,
          ssl_ca_certs='/tmp/ca-valkey.crt'
        )
        pong = myMaster.ping()
        print(pong) # should be True
        myMaster.set('mykey','myvalue')
        print(myMaster.get('mykey')) # should be myvalue
        myMaster.close()
        replicas = mySentinel.discover_slaves('my-cluster')
        for replica in replicas:
            replica_host = replica[0]
            replica_port = replica[1]
            myReplica = valkey.Valkey(host=replica_host, port=replica_port, db=0, password='1MyStrongPassword!', username='valkey', decode_responses=True, ssl=True, ssl_ca_certs='/tmp/ca-valkey.crt')
            print("replica address {} port {} mykey {}".format(replica_host, replica_port, myReplica.get('mykey'))) # should be myvalue
            myReplica.close()
         
    except Exception as ex:
        print(ex)
 
if __name__ == "__main__":
    main()
```

{% endcode %}

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://academy.cegedim.cloud/databases/valkey/valkey-get-started.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
