本文整理汇总了C++中cachedb_funcs::add方法的典型用法代码示例。如果您正苦于以下问题:C++ cachedb_funcs::add方法的具体用法?C++ cachedb_funcs::add怎么用?C++ cachedb_funcs::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cachedb_funcs
的用法示例。
在下文中一共展示了cachedb_funcs::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rl_change_counter
/* NOTE: assumes that the pipe has been locked. If fails, releases the lock */
static int rl_change_counter(str *name, rl_pipe_t *pipe, int c)
{
int new_counter;
if (rl_set_name(name) < 0)
return -1;
if (pipe->my_counter + c <= 0) {
LM_DBG("Counter going negative\n");
return 1;
}
if (cdbf.add(cdbc, &rl_name_buffer, c ? c : -(pipe->my_counter),
rl_expire_time, &new_counter) < 0){
LM_ERR("cannot change counter for pipe %.*s with %d\n",
name->len, name->s, c);
return -1;
}
pipe->my_counter = c ? pipe->my_counter + c : 0;
pipe->counter = new_counter;
LM_DBG("changed with %d; my_counter: %d; counter: %d\n",
c, pipe->my_counter, new_counter);
return 0;
}
示例2: rl_change_counter
/* NOTE: assumes that the pipe has been locked. If fails, releases the lock */
static int rl_change_counter(str *name, rl_pipe_t *pipe, int c)
{
unsigned int hid = RL_GET_INDEX(*name);
int new_counter;
RL_SET_PENDING(pipe);
RL_RELEASE_LOCK(hid);
if (rl_set_name(name) < 0)
return -1;
/* if the command should be reset */
/* XXX: This is not needed since add takes also negative numbers
if (c > 0) {
if (cdbf.add(cdbc, &rl_name_buffer, c, rl_expire_time, &new_counter)<0){
LM_ERR("cannot increase buffer for pipe %.*s\n",
name->len, name->s);
return -1;
}
} else {
if (cdbf.sub(cdbc, &rl_name_buffer, c ? c : pipe->my_counter,
rl_expire_time, &new_counter) < 0){
LM_ERR("cannot change counter for pipe %.*s with %d\n",
name->len, name->s, c);
return -1;
}
}
*/
if (cdbf.add(cdbc, &rl_name_buffer, c ? c : -(pipe->my_counter),
rl_expire_time, &new_counter) < 0){
LM_ERR("cannot change counter for pipe %.*s with %d\n",
name->len, name->s, c);
return -1;
}
RL_GET_LOCK(hid);
RL_RESET_PENDING(pipe);
pipe->my_counter = c ? pipe->my_counter + c : 0;
pipe->counter = new_counter;
LM_DBG("changed with %d; my_counter: %d; counter: %d\n",
c, pipe->my_counter, new_counter);
return 0;
}