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.
 

130 lines
3.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 SSetRequest{
string key = 1;
string field = 2;
}
//集合添加值
message SMembersRequest{
string key = 1;
}
// 设置响应结构
message SSetResponse {
int64 ret = 1;
}
//列表添加值
message LSetRequest{
string key = 1;
string field = 2;
}
// 设置key响应结构
message LSetResponse {
int64 ret = 1;
}
//列表取值
message LRangeRequest{
string key = 1;
int64 start = 2;
int64 stop = 3;
}
//列表长度
message LLenRequest{
string key = 1;
}
// rpc方法
service RedisService {
rpc Get (GetRequest) returns (GetStringResponse); // 使用key查询
rpc Set (SetRequest) returns (SetResponse);
rpc SetNx (SetRequest) returns (DelResponse); // 如果不存在则设置
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 HGetList(GetRequest) returns (HGetListResponse); //get hash all
rpc HExists(HGetRequest) returns (DelResponse); //hash键是否存在
rpc Exists(GetRequest) returns (DelResponse); //键是否存在
rpc HIncrby(HSetRequest) returns (HSetResponse); //hash数值+-1
rpc SAdd(SSetRequest) returns (SSetResponse); //添加进入集合
rpc SIsmember(SSetRequest) returns (SSetResponse); //集合中是否存在值
rpc SRem(SSetRequest) returns (SSetResponse); //集合中删除值
rpc SCard(SSetRequest) returns (SSetResponse); //获取集合的成员数
rpc LLpush(LSetRequest) returns (LSetResponse); //列表头部增加值
rpc LRpush(LSetRequest) returns (LSetResponse); //列表尾部增加值
rpc LRange(LRangeRequest) returns (HGetListResponse); //列表尾部增加值
rpc LLen(LLenRequest) returns (LSetResponse); //列表长度
rpc ReduceStock(SetRequest) returns(SetResponse);//扣减库存
}