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.

redis_pool.h 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*-
  2. * Copyright 2016 Vsevolod Stakhov
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef SRC_LIBSERVER_REDIS_POOL_H_
  17. #define SRC_LIBSERVER_REDIS_POOL_H_
  18. #include "config.h"
  19. struct rspamd_redis_pool;
  20. struct rspamd_config;
  21. struct redisAsyncContext;
  22. struct event_base;
  23. /**
  24. * Creates new redis pool
  25. * @return
  26. */
  27. struct rspamd_redis_pool *rspamd_redis_pool_init (void);
  28. /**
  29. * Configure redis pool and binds it to a specific event base
  30. * @param cfg
  31. * @param ev_base
  32. */
  33. void rspamd_redis_pool_config (struct rspamd_redis_pool *pool,
  34. struct rspamd_config *cfg,
  35. struct event_base *ev_base);
  36. /**
  37. * Create or reuse the specific redis connection
  38. * @param pool
  39. * @param db
  40. * @param password
  41. * @param ip
  42. * @param port
  43. * @return
  44. */
  45. struct redisAsyncContext* rspamd_redis_pool_connect (
  46. struct rspamd_redis_pool *pool,
  47. const gchar *db, const gchar *password,
  48. const char *ip, int port);
  49. /**
  50. * Release a connection to the pool
  51. * @param pool
  52. * @param ctx
  53. */
  54. void rspamd_redis_pool_release_connection (struct rspamd_redis_pool *pool,
  55. struct redisAsyncContext *ctx, gboolean is_fatal);
  56. /**
  57. * Stops redis pool and destroys it
  58. * @param pool
  59. */
  60. void rspamd_redis_pool_destroy (struct rspamd_redis_pool *pool);
  61. /**
  62. * Missing in hiredis
  63. * @param type
  64. * @return
  65. */
  66. const gchar* rspamd_redis_type_to_string (int type);
  67. #endif /* SRC_LIBSERVER_REDIS_POOL_H_ */