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.

93 lines
2.0 KiB

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 SAddRequest{
  63. string key = 1;
  64. string field = 2;
  65. }
  66. //集合添加值
  67. message SMembersRequest{
  68. string key = 1;
  69. }
  70. // rpc方法
  71. service RedisService {
  72. rpc Get (GetRequest) returns (GetStringResponse); // 使用key查询
  73. rpc Set (SetRequest) returns (SetResponse);
  74. rpc Del (DelRequest) returns (DelResponse);
  75. rpc HGet (HGetRequest) returns (GetStringResponse); // 使用hash key查询
  76. rpc HSet (HSetRequest) returns (HSetResponse);
  77. rpc HDel (HDelRequest) returns (DelResponse);
  78. rpc SetExpire (SetExpireRequest) returns (SetExpireResponse); //设置有效期
  79. rpc HGetAll(GetRequest) returns (HGetListResponse); //get hash all
  80. rpc HExists(HGetRequest) returns (DelResponse); //hash键是否存在
  81. rpc Exists(GetRequest) returns (DelResponse); //键是否存在
  82. rpc SAdd(SAddRequest) returns (HSetResponse); //添加进入集合
  83. rpc SIsmember(SAddRequest) returns (HSetResponse); //集合中是否存在值
  84. }