MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / cachedb_fetch

Function cachedb_fetch

cachedb/cachedb.c:411–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409}
410
411int cachedb_fetch(str* cachedb_name, str* attr, str* val)
412{
413 cachedb_engine* cde;
414 str cde_engine,grp_name;
415 char *p;
416 cachedb_con *con;
417 int ret;
418
419 if(cachedb_name == NULL || attr == NULL || val == NULL)
420 {
421 LM_ERR("null arguments\n");
422 return -1;
423 }
424
425 p = memchr(cachedb_name->s,':',cachedb_name->len);
426 if (p == NULL) {
427 cde_engine = *cachedb_name;
428 grp_name.s = NULL;
429 grp_name.len = 0;
430 LM_DBG("from script [%.*s] - no grp\n",cde_engine.len,cde_engine.s);
431 } else {
432 cde_engine.s = cachedb_name->s;
433 cde_engine.len = p - cde_engine.s;
434 grp_name.s = p+1;
435 grp_name.len = cachedb_name->len - cde_engine.len -1;
436 LM_DBG("from script [%.*s] - with grp [%.*s]\n",cde_engine.len,
437 cde_engine.s,grp_name.len,grp_name.s);
438
439 }
440
441 cde = lookup_cachedb(&cde_engine);
442 if(cde == NULL)
443 {
444 LM_ERR("Wrong argument <%.*s> - no cachedb system with"
445 " this name registered\n",
446 cde_engine.len,cde_engine.s);
447 return -1;
448 }
449
450 con = cachedb_get_connection(cde,&grp_name);
451 if (con == NULL) {
452 LM_ERR("failed to get connection for grp name [%.*s] : check db_url\n",
453 grp_name.len,grp_name.s);
454 return -1;
455 }
456
457 ret = cde->cdb_func.get(con,attr,val);
458 if (ret == 0)
459 ret++;
460
461 return ret;
462}
463
464int cachedb_counter_fetch(str* cachedb_name, str* attr, int* val)
465{

Callers 3

w_cache_fetchFunction · 0.85
mi_cachefetchFunction · 0.85
test_cachedb_apiFunction · 0.85

Calls 2

lookup_cachedbFunction · 0.85
cachedb_get_connectionFunction · 0.85

Tested by 1

test_cachedb_apiFunction · 0.68