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.

74 lines
1.4 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. string 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. uint64 expire = 2;
  36. }
  37. // 使用key查询响应结构
  38. message GetStringResponse {
  39. string value = 1;
  40. }
  41. // 设置key响应结构
  42. message SetResponse {
  43. string ret = 1;
  44. }
  45. // 删除key响应结构
  46. message DelResponse {
  47. uint64 ret = 1;
  48. }
  49. // 设置key响应结构
  50. message HSetResponse {
  51. uint64 ret = 1;
  52. }
  53. // 设置key有效期
  54. message SetExpireResponse {
  55. uint64 ret = 1;
  56. }
  57. // rpc方法
  58. service RedisService {
  59. rpc Get (GetRequest) returns (GetStringResponse); // 使用key查询
  60. rpc Set (SetRequest) returns (SetResponse);
  61. rpc Del (DelRequest) returns (DelResponse);
  62. rpc HGet (HGetRequest) returns (GetStringResponse); // 使用hash key查询
  63. rpc HSet (HSetRequest) returns (HSetResponse);
  64. rpc HDel (HDelRequest) returns (DelResponse);
  65. rpc SetExpire (SetExpireRequest) returns (SetExpireResponse); //设置有效期
  66. }