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.

167 lines
3.9 KiB

2 years ago
2 years ago
2 years ago
  1. syntax = "proto3";
  2. package redisrpc;
  3. // 使用key查询
  4. message GetRequest {
  5. string key = 1;
  6. }
  7. // 设置key
  8. message SetRequest {
  9. string key = 1;
  10. string value = 2;
  11. int64 ttl = 3;
  12. }
  13. message DelRequest {
  14. string key = 1;
  15. }
  16. // 使用hash key查询
  17. message HGetRequest {
  18. string key = 1;
  19. string field = 2;
  20. }
  21. // 设置hash key
  22. message HSetRequest {
  23. string key = 1;
  24. string field = 2;
  25. string value = 3;
  26. }
  27. // 删除hash key
  28. message HDelRequest {
  29. string key = 1;
  30. string field = 2;
  31. }
  32. //有效期
  33. message SetExpireRequest {
  34. string key = 1;
  35. int64 expire = 2;
  36. }
  37. // 使用key查询响应结构
  38. message GetStringResponse {
  39. string value = 1;
  40. }
  41. // 使用key查询响应结构
  42. message HGetListResponse {
  43. bytes list = 1;
  44. }
  45. // 设置key响应结构
  46. message SetResponse {
  47. string ret = 1;
  48. }
  49. // 删除key响应结构
  50. message DelResponse {
  51. int64 ret = 1;
  52. }
  53. // 设置key响应结构
  54. message HSetResponse {
  55. int64 ret = 1;
  56. }
  57. // 设置key有效期
  58. message SetExpireResponse {
  59. int64 ret = 1;
  60. }
  61. //集合添加值
  62. message SSetRequest{
  63. string key = 1;
  64. string field = 2;
  65. }
  66. //集合添加值
  67. message SMembersRequest{
  68. string key = 1;
  69. }
  70. // 设置响应结构
  71. message SSetResponse {
  72. int64 ret = 1;
  73. }
  74. //列表添加值
  75. message LSetRequest{
  76. string key = 1;
  77. string field = 2;
  78. }
  79. // 设置key响应结构
  80. message LSetResponse {
  81. int64 ret = 1;
  82. }
  83. //列表取值
  84. message LRangeRequest{
  85. string key = 1;
  86. int64 start = 2;
  87. int64 stop = 3;
  88. }
  89. //列表长度
  90. message LLenRequest{
  91. string key = 1;
  92. }
  93. //数值增加
  94. message AddRequest {
  95. string key = 1;
  96. int64 value = 2;
  97. }
  98. message AddResponse {
  99. int64 ret = 1;
  100. }
  101. //有序集合添加值
  102. message ZSetRequest{
  103. string key = 1;
  104. string score = 2;
  105. string member = 3;
  106. }
  107. // 设置响应结构
  108. message ZSetResponse {
  109. int64 ret = 1;
  110. }
  111. //有序集合取值
  112. message ZRangeRequest{
  113. string key = 1;
  114. int64 start = 2;
  115. int64 stop = 3;
  116. }
  117. message ZScanRequest {
  118. string key = 1;
  119. string field = 2;
  120. int64 len = 3;
  121. }
  122. // rpc方法
  123. service RedisService {
  124. rpc Get (GetRequest) returns (GetStringResponse); // 使用key查询
  125. rpc Set (SetRequest) returns (SetResponse);
  126. rpc SetNx (SetRequest) returns (DelResponse); // 如果不存在则设置
  127. rpc Del (DelRequest) returns (DelResponse);
  128. rpc HGet (HGetRequest) returns (GetStringResponse); // 使用hash key查询
  129. rpc HSet (HSetRequest) returns (HSetResponse);
  130. rpc HDel (HDelRequest) returns (DelResponse);
  131. rpc SetExpire (SetExpireRequest) returns (SetExpireResponse); //设置有效期
  132. rpc HGetAll(GetRequest) returns (HGetListResponse); //get hash all
  133. rpc HGetList(GetRequest) returns (HGetListResponse); //get hash all
  134. rpc HExists(HGetRequest) returns (DelResponse); //hash键是否存在
  135. rpc Exists(GetRequest) returns (DelResponse); //键是否存在
  136. rpc HIncrby(HSetRequest) returns (HSetResponse); //hash数值+-1
  137. rpc SAdd(SSetRequest) returns (SSetResponse); //添加进入集合
  138. rpc SIsmember(SSetRequest) returns (SSetResponse); //集合中是否存在值
  139. rpc SRem(SSetRequest) returns (SSetResponse); //集合中删除值
  140. rpc SCard(SMembersRequest) returns (SSetResponse); //获取集合的成员数
  141. rpc LLpush(LSetRequest) returns (LSetResponse); //列表头部增加值
  142. rpc LRpush(LSetRequest) returns (LSetResponse); //列表尾部增加值
  143. rpc LRange(LRangeRequest) returns (HGetListResponse); //列表尾部增加值
  144. rpc LLen(LLenRequest) returns (LSetResponse); //列表长度
  145. rpc ReduceStock(SetRequest) returns(SetResponse);//扣减库存
  146. rpc Incrby(AddRequest) returns(AddResponse);//增加
  147. rpc Decrby(AddRequest) returns(AddResponse);//减
  148. rpc ZAdd(ZSetRequest) returns (ZSetResponse); //添加进入有序集合
  149. rpc ZIncrBy(ZSetRequest) returns (ZSetResponse); //有序集合权重递增
  150. rpc ZRange(ZRangeRequest) returns (HGetListResponse);
  151. rpc ZScan(ZScanRequest) returns(HGetListResponse);//zset match
  152. }