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.

128 lines
3.0 KiB

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