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.

140 lines
3.3 KiB

3 years ago
3 years ago
3 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. // rpc方法
  102. service RedisService {
  103. rpc Get (GetRequest) returns (GetStringResponse); // 使用key查询
  104. rpc Set (SetRequest) returns (SetResponse);
  105. rpc SetNx (SetRequest) returns (DelResponse); // 如果不存在则设置
  106. rpc Del (DelRequest) returns (DelResponse);
  107. rpc HGet (HGetRequest) returns (GetStringResponse); // 使用hash key查询
  108. rpc HSet (HSetRequest) returns (HSetResponse);
  109. rpc HDel (HDelRequest) returns (DelResponse);
  110. rpc SetExpire (SetExpireRequest) returns (SetExpireResponse); //设置有效期
  111. rpc HGetAll(GetRequest) returns (HGetListResponse); //get hash all
  112. rpc HGetList(GetRequest) returns (HGetListResponse); //get hash all
  113. rpc HExists(HGetRequest) returns (DelResponse); //hash键是否存在
  114. rpc Exists(GetRequest) returns (DelResponse); //键是否存在
  115. rpc HIncrby(HSetRequest) returns (HSetResponse); //hash数值+-1
  116. rpc SAdd(SSetRequest) returns (SSetResponse); //添加进入集合
  117. rpc SIsmember(SSetRequest) returns (SSetResponse); //集合中是否存在值
  118. rpc SRem(SSetRequest) returns (SSetResponse); //集合中删除值
  119. rpc SCard(SMembersRequest) returns (SSetResponse); //获取集合的成员数
  120. rpc LLpush(LSetRequest) returns (LSetResponse); //列表头部增加值
  121. rpc LRpush(LSetRequest) returns (LSetResponse); //列表尾部增加值
  122. rpc LRange(LRangeRequest) returns (HGetListResponse); //列表尾部增加值
  123. rpc LLen(LLenRequest) returns (LSetResponse); //列表长度
  124. rpc ReduceStock(SetRequest) returns(SetResponse);//扣减库存
  125. rpc Incrby(AddRequest) returns(AddResponse);//增加
  126. rpc Decrby(AddRequest) returns(AddResponse);//减
  127. }