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.

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