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

Function cachedb_store

cachedb/cachedb.c:358–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356}
357
358int cachedb_store(str* cachedb_name, str* attr, str* val,int expires)
359{
360 cachedb_engine* cde;
361 str cde_engine,grp_name;
362 char *p;
363 cachedb_con *con;
364 int ret;
365
366 if(cachedb_name == NULL || attr == NULL || val == NULL)
367 {
368 LM_ERR("null arguments\n");
369 return -1;
370 }
371
372 p = memchr(cachedb_name->s,':',cachedb_name->len);
373 if (p == NULL) {
374 cde_engine = *cachedb_name;
375 grp_name.s = NULL;
376 grp_name.len = 0;
377 LM_DBG("from script [%.*s] - no grp\n",cde_engine.len,cde_engine.s);
378 } else {
379 cde_engine.s = cachedb_name->s;
380 cde_engine.len = p - cde_engine.s;
381 grp_name.s = p+1;
382 grp_name.len = cachedb_name->len - cde_engine.len -1;
383 LM_DBG("from script [%.*s] - with grp [%.*s]\n",cde_engine.len,
384 cde_engine.s,grp_name.len,grp_name.s);
385
386 }
387
388 cde = lookup_cachedb(&cde_engine);
389 if(cde == NULL)
390 {
391 LM_ERR("Wrong argument <%.*s> - no cachedb system with"
392 " this name registered\n",
393 cde_engine.len,cde_engine.s);
394 return -1;
395 }
396
397 con = cachedb_get_connection(cde,&grp_name);
398 if (con == NULL) {
399 LM_ERR("failed to get connection for grp name [%.*s] : check db_url\n",
400 grp_name.len,grp_name.s);
401 return -1;
402 }
403
404 ret = cde->cdb_func.set(con,attr,val,expires);
405 if (ret ==0)
406 ret++;
407
408 return ret;
409}
410
411int cachedb_fetch(str* cachedb_name, str* attr, str* val)
412{

Callers 3

w_cache_storeFunction · 0.85
mi_cachestoreFunction · 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