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

Function cachedb_sub

cachedb/cachedb.c:576–633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

574}
575
576int cachedb_sub(str* cachedb_name, str* attr, int val,int expires,int *new_val)
577{
578 cachedb_engine* cde;
579 str cde_engine,grp_name;
580 char *p;
581 cachedb_con *con;
582 int ret;
583
584 if(cachedb_name == NULL || attr == NULL)
585 {
586 LM_ERR("null arguments\n");
587 return -1;
588 }
589
590 p = memchr(cachedb_name->s,':',cachedb_name->len);
591 if (p == NULL) {
592 cde_engine = *cachedb_name;
593 grp_name.s = NULL;
594 grp_name.len = 0;
595 LM_DBG("from script [%.*s] - no grp\n",cde_engine.len,cde_engine.s);
596 } else {
597 cde_engine.s = cachedb_name->s;
598 cde_engine.len = p - cde_engine.s;
599 grp_name.s = p+1;
600 grp_name.len = cachedb_name->len - cde_engine.len -1;
601 LM_DBG("from script [%.*s] - with grp [%.*s]\n",cde_engine.len,
602 cde_engine.s,grp_name.len,grp_name.s);
603
604 }
605
606 cde = lookup_cachedb(&cde_engine);
607 if(cde == NULL)
608 {
609 LM_ERR("Wrong argument <%.*s> - no cachedb system with"
610 " this name registered\n",
611 cde_engine.len,cde_engine.s);
612 return -1;
613 }
614
615 if (!CACHEDB_CAPABILITY(&cde->cdb_func,CACHEDB_CAP_SUB)) {
616 LM_ERR("Engine %.*s does not support sub ops\n",
617 cde_engine.len,cde_engine.s);
618 return -1;
619 }
620
621 con = cachedb_get_connection(cde,&grp_name);
622 if (con == NULL) {
623 LM_ERR("failed to get connection for grp name [%.*s] : check db_url\n",
624 grp_name.len,grp_name.s);
625 return -1;
626 }
627
628 ret = cde->cdb_func.sub(con,attr,val,expires,new_val);
629 if (ret == 0)
630 ret++;
631
632 return ret;
633}

Callers 1

w_cache_subFunction · 0.85

Calls 2

lookup_cachedbFunction · 0.85
cachedb_get_connectionFunction · 0.85

Tested by

no test coverage detected