datasystem.kv_client.KVClient

datasystem.kv_client.KVClient#

class datasystem.kv_client.KVClient(host, port, connect_timeout_ms=60000, client_public_key='', client_private_key='', server_public_key='', access_key='', secret_key='', tenant_id='', enable_cross_node_connection=False, enable_exclusive_connection=False)#

KV缓存客户端。

参数:
  • host (str) - 数据系统Worker的主机IP地址。

  • port (int) - 数据系统Worker的主机IP端口号。

  • connect_timeout_ms (int) - 客户端连接和请求超时时间,单位为毫秒。默认值: 60000

  • client_public_key (str) - 用于curve认证的客户端公钥。默认值: ""

  • client_private_key (str) - 用于curve认证的客户端私钥。默认值: ""

  • server_public_key (str) - 用于curve认证的服务端公钥。默认值: ""

  • access_key (str) - AK/SK授权使用的访问密钥。默认值: ""

  • secret_key (str) - AK/SK授权的密钥。默认值: ""

  • tenant_id (str) - 租户ID。默认值: ""

  • enable_cross_node_connection (bool) - 如果为 True ,允许客户端在与当前数据系统Worker连接异常时自动切换到备用节点。默认值: False

  • enable_exclusive_connection (bool) - 实验性质特性,开启可提升client与本地datasystem_worker之间的IPC传输性能。默认值: False

输出:

KVClient

方法

init

初始化KV缓存客户端以连接到 Worker 。

set

设置键的值。

set_value

设置键的值,键由系统生成并返回。

mset

批量设置键值对。

msettx

批量设置键值对(事务操作),它保证所有的键要么都成功设置,要么都失败。

get_read_only_buffers

获取所有给定键的值。

get

获取所有给定键的值。

read

读取指定偏移量的数据。

delete

初始化KV缓存客户端以连接到 Worker 。

generate_key

生成一个带数据系统 Worker UUID 的 key。

exist

查看 key 在数据系统中是否存在。

expire

为一组键设置过期生命周期,返回函数操作状态及设置失败的键列表。