Lines Matching refs:moddata
70 moddata_clean(struct redis_moddata** moddata) { in moddata_clean() argument
71 if(!moddata || !*moddata) in moddata_clean()
73 if((*moddata)->ctxs) { in moddata_clean()
75 for(i = 0; i < (*moddata)->numctxs; i++) { in moddata_clean()
76 if((*moddata)->ctxs[i]) in moddata_clean()
77 redisFree((*moddata)->ctxs[i]); in moddata_clean()
79 free((*moddata)->ctxs); in moddata_clean()
81 free(*moddata); in moddata_clean()
82 *moddata = NULL; in moddata_clean()
86 redis_connect(const struct redis_moddata* moddata) in redis_connect() argument
90 if(moddata->server_path && moddata->server_path[0]!=0) { in redis_connect()
91 ctx = redisConnectUnixWithTimeout(moddata->server_path, in redis_connect()
92 moddata->connect_timeout); in redis_connect()
94 ctx = redisConnectWithTimeout(moddata->server_host, in redis_connect()
95 moddata->server_port, moddata->connect_timeout); in redis_connect()
104 if(redisSetTimeout(ctx, moddata->command_timeout) != REDIS_OK) { in redis_connect()
108 if(moddata->server_password && moddata->server_password[0]!=0) { in redis_connect()
110 rep = redisCommand(ctx, "AUTH %s", moddata->server_password); in redis_connect()
118 if(moddata->logical_db > 0) { in redis_connect()
120 rep = redisCommand(ctx, "SELECT %d", moddata->logical_db); in redis_connect()
123 moddata->logical_db); in redis_connect()
142 struct redis_moddata* moddata = NULL; in redis_init() local
146 moddata = calloc(1, sizeof(struct redis_moddata)); in redis_init()
147 if(!moddata) { in redis_init()
151 moddata->numctxs = env->cfg->num_threads; in redis_init()
152 moddata->ctxs = calloc(env->cfg->num_threads, sizeof(redisContext*)); in redis_init()
153 if(!moddata->ctxs) { in redis_init()
159 moddata->server_host = env->cfg->redis_server_host; in redis_init()
160 moddata->server_port = env->cfg->redis_server_port; in redis_init()
161 moddata->server_path = env->cfg->redis_server_path; in redis_init()
162 moddata->server_password = env->cfg->redis_server_password; in redis_init()
163 moddata->command_timeout.tv_sec = env->cfg->redis_timeout / 1000; in redis_init()
164 moddata->command_timeout.tv_usec = in redis_init()
166 moddata->connect_timeout.tv_sec = env->cfg->redis_timeout / 1000; in redis_init()
167 moddata->connect_timeout.tv_usec = in redis_init()
170 moddata->command_timeout.tv_sec = in redis_init()
172 moddata->command_timeout.tv_usec = in redis_init()
176 moddata->connect_timeout.tv_sec = in redis_init()
178 moddata->connect_timeout.tv_usec = in redis_init()
181 moddata->logical_db = env->cfg->redis_logical_db; in redis_init()
182 for(i = 0; i < moddata->numctxs; i++) { in redis_init()
183 redisContext* ctx = redis_connect(moddata); in redis_init()
188 moddata->ctxs[i] = ctx; in redis_init()
190 cachedb_env->backend_data = moddata; in redis_init()
220 moddata_clean(&moddata); in redis_init()
227 struct redis_moddata* moddata = (struct redis_moddata*) in redis_deinit() local
232 moddata_clean(&moddata); in redis_deinit()