当前位置:网站首页>【深入理解TcaplusDB技术】删除数据示例代码——[Generic表]
【深入理解TcaplusDB技术】删除数据示例代码——[Generic表]
2022-04-22 15:01:00 【数据库大师】
本文准备工作
参见章节: 准备工作。
示例代码
示例代码
import com.tencent.tcaplus.client.Client;
import com.tencent.tcaplus.client.ClientFactory;
import com.tencent.tcaplus.client.Record;
import com.tencent.tcaplus.client.Request;
import com.tencent.tcaplus.client.Response;
import com.tencent.tdr.tcaplus_protocol_cs.TcaplusProtocolCsConstants;
import java.util.ArrayList;
import java.util.List;
public class Example {
public static void main(String[] arguments) {
// 1. 准备环境信息
// 1.1. 目录服务地址列表
List<String> dirList = new ArrayList<String>();
dirList.add("tcp://x.x.x.x:9999");
dirList.add("tcp://y.y.y.y:9999");
// 1.2. 业务ID
int appId = 1;
// 1.3. 业务密码
String appPassword = "****************";
// 1.4. 表格组ID
int tableGroupId = 1;
// 1.5. 表格名称
String tableName = "test";
// 2. 创建客户端
Client client = ClientFactory.createClient(appId, tableGroupId, appPassword, dirList);
try {
// 3. 构造删除数据的请求
// 3.1. 获取请求对象。为了提升SDK性能,Request对象是复用的
Request request = client.acquireRequest();
// 3.2. 设置请求类型和目标表名
request.setCmd(TcaplusProtocolCsConstants.TCAPLUS_CMD_DELETE_REQ);
request.setTableName(tableName);
// 3.3. 设置各Key字段的值
Record record = request.addRecord();
record.setKeyInt("gameid", 1);
record.setKeyInt("itemid", 1);
record.setKeyString("name", "test");
// 4. 发送请求,并获取结果
Response response = client.poll(request);
// 5. 处理结果
if (response.getResult() == 0) {
// 删除数据成功
// TODO 可在此处添加数据删除成功的后续处理代码
} else {
// 删除数据失败
// TODO 可在此处添加数据删除失败的后续处理代码
}
} finally {
// 6. 销毁客户端对象
ClientFactory.destroyClient(client);
}
}
}

TcaplusDB是腾讯出品的分布式NoSQL数据库,存储和调度的代码完全自研。具备缓存+落地融合架构、PB级存储、毫秒级时延、无损水平扩展和复杂数据结构等特性。同时具备丰富的生态、便捷的迁移、极低的运维成本和五个九高可用等特点。客户覆盖游戏、互联网、政务、金融、制造和物联网等领域。
版权声明
本文为[数据库大师]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Tcapshuju/article/details/124338984
边栏推荐
- Construction of information research and judgment analysis platform and development of information, guidance and logistics integrated management system
- Operation of simulated examination platform for examination questions of safety production management personnel of hazardous chemical production units in 2022
- 数据库操作
- 思科模拟器EVE-NG如何导入镜像
- 2022 operation of simulated test question bank and simulated test platform for main principals of hazardous chemicals business units
- Leetcode interview question 17.16 Masseur (simple)
- 入参有汉字,报错500,服务器内部错误
- STM32将采集数据以TXT文件形式保存在SD卡的操作实战,小小单片机系统也能便携取出大量本地数据(SD卡+FATFS)
- 查看自己的系统激活类型
- [ELT. Zip] comments on CCF open source college trip phase I
猜你喜欢

Android的UI---ZoomControls放大缩小图片,android面试简历模板
![[C language] learn file operation in 10 minutes](/img/90/947c63e86f4237bbd808126de1c656.png)
[C language] learn file operation in 10 minutes

数学史有没有必要读?关于数学教育,我们忽视了太多

职场PUA,管理者的五宗罪

memcpy( )函数复制二维数组 & memcmp( )函数比较二维数组

使用 MyCat 配置 MySQL 集群(2)—— 配置 MySQL 主从复制

share memory的bank conflict分析

关于阿里云OSS资源STS访问控制

Shortcut key delete browser cache, windows combination key, CMD shortcut command

*CTF2022 - Web
随机推荐
[interpretation of orb_slam2 source code] Analyze orb_ How does slam2 rgbd calculate the position and attitude in frame 0
C语言的基本练习(001-1)
When allowCredentials is true, allowedOrigins cannot contain the special value “*“ since that canno
When border collapse is collapse, why doesn't the padding of the outermost box work
leetcode1025. 除数博弈(简单)
2022茶艺师(中级)考试题及答案
ROS通信机制二---服务通信
A young man's first acquaintance
Development trend of C in 2022
vscode settings. JSON location
跨域处理的几种方案
Operation of simulated examination platform for examination questions of safety production management personnel of hazardous chemical production units in 2022
预处理是程序的历程
情报研判分析平台建设,情指勤一体化管理系统开发
Take you to understand the principle of highly flexible spark architecture
When there is only input and output in flinksql, it will be merged into a subtask. In this case, the amount of input and output data cannot be displayed?
Liunx常用命令
入参有汉字,报错500,服务器内部错误
思科模拟器EVE-NG如何导入镜像
琢磨琢磨方法引用以及lambda--白话Lambda和方法引用