* init module function */
| 515 | * init module function |
| 516 | */ |
| 517 | static int mod_init(void) |
| 518 | { |
| 519 | cachedb_engine cde; |
| 520 | |
| 521 | LM_INFO("initializing module cachedb_sql...\n"); |
| 522 | memset(&cde, 0, sizeof cde); |
| 523 | |
| 524 | db_table.len = strlen(db_table.s); |
| 525 | key_column.len = strlen(key_column.s); |
| 526 | value_column.len = strlen(value_column.s); |
| 527 | counter_column.len = strlen(counter_column.s); |
| 528 | expires_column.len = strlen(expires_column.s); |
| 529 | |
| 530 | /* register the cache system */ |
| 531 | cde.name = cache_mod_name; |
| 532 | |
| 533 | cde.cdb_func.init = dbcache_init; |
| 534 | cde.cdb_func.destroy = dbcache_destroy; |
| 535 | cde.cdb_func.get = dbcache_get; |
| 536 | cde.cdb_func.set = dbcache_set; |
| 537 | cde.cdb_func.remove = dbcache_remove; |
| 538 | cde.cdb_func.add = dbcache_add; |
| 539 | cde.cdb_func.sub = dbcache_sub; |
| 540 | cde.cdb_func.get_counter = dbcache_fetch_counter; |
| 541 | cde.cdb_func.capability = 0; |
| 542 | |
| 543 | if(cache_clean_period <= 0) { |
| 544 | LM_ERR("wrong parameter cache_clean_period - need a positive value\n"); |
| 545 | return -1; |
| 546 | } |
| 547 | |
| 548 | if(register_cachedb(&cde) < 0) { |
| 549 | LM_ERR("failed to register to core memory store interface\n"); |
| 550 | return -1; |
| 551 | } |
| 552 | |
| 553 | /* register timer to delete the expired entries */ |
| 554 | register_timer("cachedb_sql",dbcache_clean, 0, cache_clean_period, |
| 555 | TIMER_FLAG_DELAY_ON_DELAY); |
| 556 | |
| 557 | return 0; |
| 558 | } |
| 559 | |
| 560 | /** |
| 561 | * Initialize children |
nothing calls this directly
no test coverage detected