redis rpc服务, 提供redis操作方法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

94 lines
2.0 KiB

syntax = "proto3";
package redisrpc;
// 使用key查询
message GetRequest {
string key = 1;
}
// 设置key
message SetRequest {
string key = 1;
string value = 2;
int64 ttl = 3;
}
message DelRequest {
string key = 1;
}
// 使用hash key查询
message HGetRequest {
string key = 1;
string field = 2;
}
// 设置hash key
message HSetRequest {
string key = 1;
string field = 2;
string value = 3;
}
// 删除hash key
message HDelRequest {
string key = 1;
string field = 2;
}
//有效期
message SetExpireRequest {
string key = 1;
int64 expire = 2;
}
// 使用key查询响应结构
message GetStringResponse {
string value = 1;
}
// 使用key查询响应结构
message HGetListResponse {
bytes list = 1;
}
// 设置key响应结构
message SetResponse {
string ret = 1;
}
// 删除key响应结构
message DelResponse {
int64 ret = 1;
}
// 设置key响应结构
message HSetResponse {
int64 ret = 1;
}
// 设置key有效期
message SetExpireResponse {
int64 ret = 1;
}
//集合添加值
message SAddRequest{
string key = 1;
string field = 2;
}
//集合添加值
message SMembersRequest{
string key = 1;
}
// rpc方法
service RedisService {
rpc Get (GetRequest) returns (GetStringResponse); // 使用key查询
rpc Set (SetRequest) returns (SetResponse);
rpc Del (DelRequest) returns (DelResponse);
rpc HGet (HGetRequest) returns (GetStringResponse); // 使用hash key查询
rpc HSet (HSetRequest) returns (HSetResponse);
rpc HDel (HDelRequest) returns (DelResponse);
rpc SetExpire (SetExpireRequest) returns (SetExpireResponse); //设置有效期
rpc HGetAll(GetRequest) returns (HGetListResponse); //get hash all
rpc HExists(HGetRequest) returns (DelResponse); //hash键是否存在
rpc Exists(GetRequest) returns (DelResponse); //键是否存在
rpc SAdd(SAddRequest) returns (HSetResponse); //添加进入集合
rpc SIsmember(SAddRequest) returns (HSetResponse); //集合中是否存在值
}