Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion src/content/docs/en/pages/devtools/azion-lib/usage/client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ menu_namespace: libMenu

import LinkButton from 'azion-webkit/linkbutton'

The Azion **Client** interface provides a unified interface to interact with all products and services. You can use the `client` to access and manage all products and functionalities across Storage, SQL, Purge, and more.
The Azion **Client** interface provides a unified interface to interact with all products and services. You can use the `client` to access and manage all products and functionalities across Storage, SQL, Purge, KV, Domains, and more.

When instantiating a client, you can define configurations such as `token` and `debug` explicitly as parameters. You can then interact with Azion functionalities directly through the `client`, in a simplified and centralized way.

Expand Down Expand Up @@ -103,3 +103,50 @@ if (data) {
```

This flexibility allows you to either manage everything through the client for simplicity or call specific functions from each package with more control over environment configurations.

---

## Available modules

The Azion Client provides access to the following modules:

| Module | Description |
|--------|-------------|
| `storage` | Manage buckets and objects in Object Storage. |
| `sql` | Create and query SQL databases. |
| `purge` | Purge cache by URL, cache key, or wildcard. |
| `domains` | Manage domains and their configurations. |
| `kv` | Interact with KV Store using a Redis-like API. |

### Using the KV module

The `kv` module provides a Redis-like interface for key-value operations:

```typescript
import { createClient } from 'azion';

const client = createClient({ token: 'your-api-token', debug: true });

// Access the KV module
const kvClient = await client.kv
.on('error', (err) => console.error('KV Error:', err))
.connect();

// Store a value
await kvClient.set('user:123', JSON.stringify({ name: 'John' }), {
expiration: { type: 'EX', value: 3600 }, // 1 hour TTL
});

// Retrieve a value
const userData = await kvClient.get('user:123');
console.log('User data:', userData);

// Hash operations
await kvClient.hSet('config', 'theme', 'dark');
const config = await kvClient.hGetAll('config');

// Disconnect when done
await kvClient.disconnect();
```

For more details on KV operations, see the [KV library documentation](/en/documentation/products/azion-lib/kv/).
Loading