Help Center/ GeminiDB/ API Reference/ APIs v3 (Recommended)/ Instances/ Creating a Memory Acceleration Rule
Updated on 2025-11-17 GMT+08:00

Creating a Memory Acceleration Rule

Function

This API is used to create a memory acceleration rule.

Constraints

This API can be used only on primary/standby GeminiDB Redis instances.

Authorization

Each account is authorized to call all APIs, but its IAM users must be granted necessary permissions. For details, see Permission Policies and Supported Actions.

URI

POST /v3/{project_id}/dbcache/rule

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Explanation:

Project ID of a tenant in a region. To obtain this value, see Obtaining a Project ID.

Constraints:

N/A

Values:

N/A

Default value:

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Explanation:

User token

You can obtain the token by calling the IAM API by following Obtaining a User Token Through Password Authentication.

Constraints:

N/A

Values:

N/A

Default value:

N/A

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

dbcache_mapping_id

Yes

String

Explanation:

Memory acceleration mapping ID

Constraints:

N/A

Values:

N/A

Default value:

N/A

name

Yes

String

Explanation:

Name of a memory acceleration rule

Constraints:

N/A

Values:

The value can contain a maximum of 256 characters and must be unique in the current mapping.

Default value:

N/A

source_db_schema

Yes

String

Explanation:

Source database

Constraints:

N/A

Values:

N/A

Default value:

N/A

source_db_table

Yes

String

Explanation:

Source database table

Constraints:

N/A

Values:

N/A

Default value:

N/A

storage_type

Yes

String

Explanation:

Storage type of the destination database

Constraints:

N/A

Values:

hash

Default value:

N/A

target_database

Yes

String

Explanation:

Destination database

Constraints:

N/A

Values:

0999

Default value:

N/A

key_columns

Yes

Array of strings

Explanation:

Columns used by mapped keys

Constraints:

N/A

Values:

N/A

Default value:

N/A

value_columns

Yes

Array of strings

Explanation:

Columns used by mapped values

Constraints:

N/A

Values:

N/A

Default value:

N/A

ttl

No

String

Explanation:

Lifetime of a key (unit: ms)

Constraints:

N/A

Values:

N/A

Default value:

If this parameter is not transferred, default value 2592000000 is used, indicating 30 days.

key_separator

Yes

String

Explanation:

Key separator of a mapping

Constraints:

N/A

Values:

Only one character is allowed.

Default value:

N/A

value_separator

No

String

Explanation:

Value separator of a mapping

Constraints:

Only one character is allowed.

Values:

N/A

Default value:

N/A

key_prefix

Yes

String

Explanation:

Key prefix

Constraints:

The value can contain no more than 1,024 characters. key_prefix and target_database must be unique in the current mapping.

Values:

N/A

Default value:

N/A

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

id

String

Explanation:

ID of a memory acceleration rule

Values:

N/A

Example Request

Creating a memory acceleration rule

POST https://{endpoint}/v3/054e292c9880d4992f02c0196d3ea468/dbcache/rule 
 
{ 
  "dbcache_mapping_id" : "e6f8526c-8b9c-4811-9218-4d2d7c1ddde1", 
  "name" : "mysql_a1-to-redis_01", 
  "source_db_schema" : "test", 
  "source_db_table" : "students_info_t", 
  "storage_type" : "hash", 
  "target_database" : "0", 
  "key_columns" : [ "sno", "sname" ], 
  "value_columns" : [ "sno", "sname", "age" ], 
  "ttl" : "-1", 
  "key_separator" : ":", 
  "key_prefix" : "prefix1" 
}

Example Response

Status code: 200

Successful request

{ 
  "id" : "04efe8e2-9255-44ae-a98b-d87cae411890" 
}

Status Codes

See Status Codes.

Error Codes

See Status Codes.