redis_client.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * $Id$
  3. *
  4. * Copyright (C) 2011 Daniel-Constantin Mierla (asipto.com)
  5. *
  6. * This file is part of Kamailio, a free SIP server.
  7. *
  8. * Kamailio is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * Kamailio is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. */
  23. #ifndef _REDIS_CLIENT_H_
  24. #define _REDIS_CLIENT_H_
  25. #include <hiredis/hiredis.h>
  26. #include "../../str.h"
  27. #include "../../parser/parse_param.h"
  28. #include "../../mod_fix.h"
  29. int redisc_init(void);
  30. int redisc_destroy(void);
  31. int redisc_add_server(char *spec);
  32. int redisc_exec(str *srv, str *res, str *cmd, ...);
  33. typedef struct redisc_server {
  34. str *sname;
  35. unsigned int hname;
  36. param_t *attrs;
  37. redisContext *ctxRedis;
  38. struct redisc_server *next;
  39. } redisc_server_t;
  40. typedef struct redisc_reply {
  41. str rname;
  42. unsigned int hname;
  43. redisReply *rplRedis;
  44. struct redisc_reply *next;
  45. } redisc_reply_t;
  46. typedef struct redisc_pv {
  47. str rname;
  48. redisc_reply_t *reply;
  49. str rkey;
  50. int rkeyid;
  51. gparam_t pos; /* Array element position. */
  52. } redisc_pv_t;
  53. /* Server related functions */
  54. redisc_server_t* redisc_get_server(str *name);
  55. int redisc_reconnect_server(redisc_server_t *rsrv);
  56. /* Command related functions */
  57. int redisc_exec(str *srv, str *res, str *cmd, ...);
  58. void* redisc_exec_argv(redisc_server_t *rsrv, int argc, const char **argv, const size_t *argvlen);
  59. redisc_reply_t *redisc_get_reply(str *name);
  60. int redisc_free_reply(str *name);
  61. #endif