-
Notifications
You must be signed in to change notification settings - Fork 7
/
redispool.h
33 lines (23 loc) · 912 Bytes
/
redispool.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef __REDIS_CONNECTION_POOL_H
#define __REDIS_CONNECTION_POOL_H
#include <hiredis/hiredis.h>
#include <pthread.h>
#define REDISPOOL_MAJOR 0
#define REDISPOOL_MINOR 1
#define REDISPOOL_SONAME 0.1
typedef struct redisConnectionPool {
redisContext **connections;
int allowedConnections;
int usedConnections;
pthread_mutex_t lock;
const char *hostname;
int port;
struct timeval timeout;
} redisConnectionPool;
void redisFreeConnectionPool(redisConnectionPool *pool);
redisConnectionPool *redisCreateConnectionPool(int size, const char *hostname, int port, struct timeval timeout);
void redisPutConnectionInConnectionPool(redisContext *c, redisConnectionPool *pool);
redisContext *redisGetConnectionFromConnectionPool(redisConnectionPool *pool);
int redisConnectionsInConnectionPool(redisConnectionPool *pool);
int redisConnectionPoolDepth(redisConnectionPool *pool);
#endif