MCPcopy Create free account
hub / github.com/acl-dev/acl / peek_conn

Method peek_conn

lib_acl_cpp/src/redis/redis_client_cluster.cpp:279–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277}
278
279redis_client* redis_client_cluster::peek_conn(int slot)
280{
281 // ����Ѿ������˹�ϣ��ֵ�������ȴӱ��ػ����в��Ҷ�Ӧ�����ӳ�
282 // ���δ�ҵ���������м�Ⱥ����������һ�����õ����ӳض���
283
284 redis_client_pool* conns;
285 redis_client* conn;
286 int i = 0;
287
288 while (i++ < 5) {
289 if (slot < 0) {
290 conns = (redis_client_pool*) this->peek();
291 } else if ((conns = peek_slot(slot)) == NULL) {
292 conns = (redis_client_pool*) this->peek();
293 }
294
295 if (conns == NULL) {
296 slot = -1;
297 continue;
298 }
299
300 conn = (redis_client*) conns->peek();
301 if (conn != NULL) {
302 return conn;
303 }
304
305 // ȡ����ϣ�۵ĵ�ַӳ���ϵ
306 clear_slot(slot);
307
308#ifdef AUTO_SET_ALIVE
309 // �����ӳض�����Ϊ������״̬
310 conns->set_alive(false);
311#endif
312 }
313
314 logger_warn("too many retry: %d, slot: %d", i, slot);
315 return NULL;
316}
317
318redis_client* redis_client_cluster::reopen(redis_command& cmd,
319 redis_client* conn)

Callers

nothing calls this directly

Calls 2

peekMethod · 0.45
set_aliveMethod · 0.45

Tested by

no test coverage detected