This topic describes how to create and attach a KVCacheStore, deploy the data access components, and use an SDK to perform KV operations.
Prerequisites
-
Obtain the AccessKey ID and AccessKey secret of your Alibaba Cloud account. Make sure that the account has permissions to call KVCacheStore management APIs.
-
Prepare an Intelligent Computing Lingjun bare metal node that is associated with a virtual storage cluster (VSC). You use this node to deploy
kvcs-efcand run applications that call the SDK. -
Prepare the VSC to which you want to attach the KVCacheStore and obtain the VSC ID. In this example, the KVCacheStore and the VSC belong to the same Alibaba Cloud account.
-
Make sure that the KVCacheStore and the compute node can communicate over the network. Select the region, zone, and high-performance network (HPN) cluster based on the location of the compute node.
Create a KVCacheStore
Billing starts immediately after you create a KVCacheStore and stops after you delete it. The minimum capacity is 300 TiB. Capacity can be increased in increments of 300 TiB.
Console
-
Log on to the KVCacheStore console. You can switch regions at the top of the page.
-
Click Create KVCacheStore and configure the resource.
-
Click Create Now and follow the on-screen instructions to place the order.
API
You can run this operation in OpenAPI Explorer, which eliminates the need to manually calculate signatures. After a successful call, OpenAPI Explorer can automatically generate SDK code samples.
Call the CreateKVCacheStore operation to create a pay-as-you-go KVCacheStore. Sample request:
POST /?Action=CreateKVCacheStore&Version=2026-06-17 HTTP/1.1
Host: kvcachestore.cn-wulanchabu.aliyuncs.com
Content-Type: application/x-www-form-urlencoded
RegionId=cn-wulanchabu
&ZoneId=cn-wulanchabu-a
&HpnZone=A1
&Capacity=307200
&Name=my-kvcachestore
&ChargeType=POSTPAY
&ClientToken=0d796d82-9fcf-4616-84be-92758f70ed54
Sample success response:
{
"RequestId": "019F6A7C-DFBB-16BA-BCD3-5C6F6B16D67B",
"KvcsId": "kvcs-cn-xxxxxxxxxxxx",
"OrderId": "299101502720755"
}
This operation is asynchronous. After the operation returns the KVCacheStore ID, wait until the KVCacheStore enters the Available state before you attach it.
Attach the KVCacheStore
Obtain the mount point
Before the KVCacheStore is attached, its state returned by the API is Available, and its state displayed in the console is Pending Mount. You can then obtain the mount point in the console or by calling an API operation.
Console
-
Log on to the KVCacheStore console. You can switch regions at the top of the page.
-
Click the KVCacheStore ID or Details in the Actions column. View the Mount Target information.
API
You can run this operation in OpenAPI Explorer, which eliminates the need to manually calculate signatures. After a successful call, OpenAPI Explorer can automatically generate SDK code samples.
Call the GetKVCacheStore operation to query the KVCacheStore. Obtain the mount point from the MountPointId field in the response. Sample request:
POST /?Action=GetKVCacheStore&Version=2026-06-17 HTTP/1.1
Host: kvcachestore.cn-wulanchabu.aliyuncs.com
Content-Type: application/x-www-form-urlencoded
RegionId=cn-wulanchabu
&KvcsId=kvcs-cn-xxxxxxxxxxxx
Sample success response:
{
"RequestId": "019F6A5F-84DC-186B-95F4-1B93AC79DAE5",
"KvCacheStore": {
"KvcsId": "kvcs-cn-xxxxxxxxxxxx",
"Name": "my-kvcachestore",
"Status": "Available",
"ExtraStatus": "CapacityExpandSuccess",
"RegionId": "cn-wulanchabu",
"ZoneId": "cn-wulanchabu-a",
"HpnZone": "A1",
"Type": "kvcs",
"Capacity": 307200,
"PaymentType": "POSTPAY",
"MountPointId": "kvcs-cn-xxxxxxxxxxxx-000001.cn-wulanchabu.kvcachestore.aliyuncs.com",
"CreateTime": "2026-07-14T07:19:00Z",
"Description": "KVCacheStore for production workloads"
}
}
Attach the KVCacheStore by using the API
You can attach a KVCacheStore to a VSC only by calling an OpenAPI operation. The following example applies when the KVCacheStore and the VSC belong to the same Alibaba Cloud account.
You can run this operation in OpenAPI Explorer, which eliminates the need to manually calculate signatures. After a successful call, OpenAPI Explorer can automatically generate SDK code samples.
After the state of the KVCacheStore returned by the API changes to Available, call the AttachKVCacheStore operation to attach the KVCacheStore:
POST /?Action=AttachKVCacheStore&Version=2026-06-17 HTTP/1.1
Host: kvcachestore.cn-wulanchabu.aliyuncs.com
Content-Type: application/x-www-form-urlencoded
RegionId=cn-wulanchabu
&ResourceIds.1.KvcsId=kvcs-cn-xxxxxxxxxxxx
&ResourceIds.1.VscId=vsc-xxxxxxxxxxxx
Sample success response:
{
"RequestId": "019F6AF0-5A2F-1AB1-BF90-8A9E5979B5F5",
"AttachResults": [
{
"KvcsId": "kvcs-cn-xxxxxxxxxxxx",
"VscId": "vsc-xxxxxxxxxxxx",
"Status": "Attaching"
}
]
}
This operation is asynchronous. The Attaching state indicates that the request is accepted. Call the ListKVCacheStoreAttachInfo operation to query the attachment record. When the state of the record changes to Attached, the KVCacheStore is attached. The state displayed in the console changes to In Use.
Configure the data access environment
Attaching a KVCacheStore by using OpenAPI establishes a resource association between the KVCacheStore and the VSC. After the KVCacheStore is attached, deploy kvcs-efc and install kvcs-sdk on the compute node. Your application uses the SDK to access a local Unix socket, and kvcs-efc forwards the requests to the KVCacheStore.
Deploy kvcs-efc
kvcs-efc is a background process deployed on the compute node. Before deployment, make sure that the compute node supports systemd and has curl and tar installed. Root or sudo permissions are required.
Run the following commands on the compute node to download and start the interactive installation script:
curl -fsSL https://kvcachestore.oss-accelerate.aliyuncs.com/scripts/install-kvcs.sh -o install-kvcs.sh
bash install-kvcs.sh
When prompted, enter the mount point, such as kvcs-cn-xxxxxxxxxxxx-000001.cn-wulanchabu.kvcachestore.aliyuncs.com.
The installation script downloads and configures kvcs-efc, downloads the SDKs to /opt/kvcs-sdk/latest, and starts the kvcs-efc service. After installation, run the following command to verify that the communication socket is created:
test -S /var/run/kvcs/efc-grpc.sock && echo "kvcs-efc is ready"
Install an SDK
When you install kvcs-efc, the installation script downloads the Python, Go, and Rust SDKs to /opt/kvcs-sdk/latest. Integrate the SDK for the programming language used by your application.
Python
Make sure that Python 3.9 or later is installed. Then, install the Python SDK and verify the installation:
python3 --version
python3 -m pip install /opt/kvcs-sdk/latest/python/
python3 -c "from kvcs import KvcsLowLevelClient; print('OK')"
Go
Make sure that Go 1.25 or later is installed. Add the following content to the go.mod file of your project to reference the local Go SDK:
require github.com/alibaba/kvcachestore-sdk/go v0.0.0
replace github.com/alibaba/kvcachestore-sdk/go => /opt/kvcs-sdk/latest/go
Configure the SDK build and runtime environment, and then build the project:
source /opt/kvcs-sdk/latest/env.sh
go build ./...
Rust
Make sure that Rust and Cargo are installed. Add the following content to the Cargo.toml file of your project to reference the local Rust SDK:
[dependencies]
kvcs = { path = "/opt/kvcs-sdk/latest/rust" }
Configure the SDK build and runtime environment, and then build the project:
source /opt/kvcs-sdk/latest/env.sh
cargo build
The application process that uses kvcs-sdk and the kvcs-efc process must run as the same operating system user.
Perform KV operations
The following examples use the local /var/run/kvcs/efc-grpc.sock socket to communicate with kvcs-efc. The examples write, read, query, and delete the k1 key in sequence. Batch Get supports copy-out and copy-into methods. The copy-out method lets the SDK allocate memory and return the data, and is suitable for typical reads. The copy-into method writes data to caller-provided buffers, which you can reuse to reduce repeated allocations and garbage collection overhead. For the copy-into method, provide one sufficiently large buffer for each key.
Python
from kvcs import KvcsLowLevelClient, LLPutItem, LLGetItemOpt
client = KvcsLowLevelClient(efc_socket="/var/run/kvcs/efc-grpc.sock")
put_results = client.ll_batch_put(
[LLPutItem(key="k1", value=b"v1")],
deadline_s=10.0,
)
print("ll_batch_put status:", put_results[0].status)
# Copy-out: The SDK allocates memory and returns the data.
get_results = client.ll_batch_get_items(
[LLGetItemOpt(key="k1")],
deadline_s=10.0,
)
assert get_results[0].data == b"v1"
print("ll_batch_get_items data:", get_results[0].data)
# Copy-into: Data is written directly to a caller-provided buffer.
buf = bytearray(1024)
get_into_results = client.ll_batch_get_into_items(
[LLGetItemOpt(key="k1")],
[buf],
deadline_s=10.0,
)
actual_len = get_into_results[0].data_len
assert buf[:actual_len] == b"v1"
print("ll_batch_get_into_items data:", bytes(buf[:actual_len]))
query_results = client.ll_batch_query(["k1"])
print("ll_batch_query status:", query_results[0].status)
delete_results = client.ll_batch_delete(["k1"], deadline_s=10.0)
print("ll_batch_delete status:", delete_results[0])
client.close()
Go
package main
import (
"context"
"fmt"
"time"
kvcs "github.com/alibaba/kvcachestore-sdk/go"
)
func main() {
client, err := kvcs.NewKvcsLowLevelClient(kvcs.KvcsLowLevelConfig{
EFCSocket: "/var/run/kvcs/efc-grpc.sock",
})
if err != nil {
panic(err)
}
defer client.Close()
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
putResults, err := client.LLBatchPut(ctx, []kvcs.LLPutItem{
{Key: "k1", Value: [][]byte{[]byte("v1")}},
})
if err != nil {
panic(err)
}
fmt.Println("LLBatchPut status:", putResults[0].Status)
// Copy-out: The SDK allocates memory and returns the data.
getResults, err := client.LLBatchGetItems(ctx, []kvcs.LLGetItemOpt{
{Key: "k1"},
})
if err != nil {
panic(err)
}
fmt.Println("LLBatchGetItems data:", string(getResults[0].Data))
// Copy-into: Data is written directly to a caller-provided buffer.
buf := make([]byte, 1024)
getIntoResults, err := client.LLBatchGetIntoItems(ctx,
[]kvcs.LLGetItemOpt{{Key: "k1"}},
[][]byte{buf},
)
if err != nil {
panic(err)
}
actualLen := getIntoResults[0].DataLen
fmt.Println("LLBatchGetIntoItems data:", string(buf[:actualLen]))
queryResults, err := client.LLBatchQuery(ctx, []string{"k1"})
if err != nil {
panic(err)
}
fmt.Println("LLBatchQuery status:", queryResults[0].Status)
deleteResults, err := client.LLBatchDelete(ctx, []string{"k1"})
if err != nil {
panic(err)
}
fmt.Println("LLBatchDelete status:", deleteResults[0])
}
Rust
use kvcs::*;
use std::time::Duration;
fn main() {
let client = KvcsLowLevelClient::new(KvcsLowLevelConfig {
efc_socket: "/var/run/kvcs/efc-grpc.sock".into(),
..Default::default()
}).unwrap();
let deadline = Some(Duration::from_secs(10));
let opts = LLBatchOptions::default();
let put_results = client.ll_batch_put(&[LLPutItem {
key: "k1",
value: &[b"v1"],
}], deadline, opts).unwrap();
println!("ll_batch_put status: {}", put_results[0].status);
// Copy-out: The SDK allocates memory and returns the data.
let get_results = client.ll_batch_get_items(
&[LLGetItemOpt { key: "k1" }],
deadline,
opts,
).unwrap();
assert_eq!(get_results[0].data.as_deref(), Some(b"v1".as_slice()));
println!("ll_batch_get_items data: {:?}", get_results[0].data);
// Copy-into: Data is written directly to a caller-provided buffer.
let mut buf = vec![0u8; 1024];
let get_into_results = client.ll_batch_get_into_items(
&[LLGetItemOpt { key: "k1" }],
&mut [&mut buf[..]],
deadline,
opts,
).unwrap();
let actual_len = get_into_results[0].data_len;
assert_eq!(&buf[..actual_len], b"v1");
println!("ll_batch_get_into_items data: {:?}", &buf[..actual_len]);
let query_results = client.ll_batch_query(&["k1"], opts).unwrap();
println!("ll_batch_query status: {}", query_results[0].status);
let delete_results = client.ll_batch_delete(&["k1"], deadline, opts).unwrap();
println!("ll_batch_delete status: {}", delete_results[0]);
}
Clean up resources
If you no longer need the KVCacheStore after you complete the tutorial, detach and then delete it. Billing stops after the KVCacheStore is deleted. This prevents unnecessary storage charges.
Detach the KVCacheStore
Before you detach the KVCacheStore, stop all applications that call the SDK to ensure that no KV requests are sent to the KVCacheStore.
You can run this operation in OpenAPI Explorer, which eliminates the need to manually calculate signatures. After a successful call, OpenAPI Explorer can automatically generate SDK code samples.
Call the DetachKVCacheStore operation to remove the attachment between the KVCacheStore and the VSC in the same Alibaba Cloud account:
POST /?Action=DetachKVCacheStore&Version=2026-06-17 HTTP/1.1
Host: kvcachestore.cn-wulanchabu.aliyuncs.com
Content-Type: application/x-www-form-urlencoded
RegionId=cn-wulanchabu
&ResourceIds.1.KvcsId=kvcs-cn-xxxxxxxxxxxx
&ResourceIds.1.VscId=vsc-xxxxxxxxxxxx
Sample success response:
{
"RequestId": "019F6AF0-B7A7-1E92-B77B-A99FC8F7F0E9",
"DetachResults": [
{
"KvcsId": "kvcs-cn-xxxxxxxxxxxx",
"VscId": "vsc-xxxxxxxxxxxx",
"Status": "Detaching"
}
]
}
This operation is asynchronous. The Detaching state indicates that the request is accepted. Call the ListKVCacheStoreAttachInfo operation to query the attachment record. If no record is found for the specified KVCacheStore ID and VSC ID, the KVCacheStore is detached.
Delete the KVCacheStore
You can run this operation in OpenAPI Explorer, which eliminates the need to manually calculate signatures. After a successful call, OpenAPI Explorer can automatically generate SDK code samples.
After you confirm that the KVCacheStore is detached, call the DeleteKVCacheStore operation to delete the KVCacheStore. This operation is irreversible. All data in the KVCacheStore is permanently deleted:
POST /?Action=DeleteKVCacheStore&Version=2026-06-17 HTTP/1.1
Host: kvcachestore.cn-wulanchabu.aliyuncs.com
Content-Type: application/x-www-form-urlencoded
RegionId=cn-wulanchabu
&KvcsId=kvcs-cn-xxxxxxxxxxxx
Sample success response:
{
"RequestId": "019F6A7C-8A57-1B39-9378-BC0C3C9928E2",
"KvcsId": "kvcs-cn-xxxxxxxxxxxx"
}