[OpenSIPS-Devel] [Memcached module] Adding cache_increment/cache_decrement methods

Andrei Dragus adragus at opensips.org
Mon Feb 22 11:31:08 CET 2010


Hi there,

> 1. cache_fetch, cache_store and cache_remove are not exported by the 
> memcached module anywhere. How then are we able to use them from 
> opensips.cfg ?
     There is a layer of abstractization called memcache(in the core)
which can be implemented in two ways "memcached" or "localcache" (both
are modules). The parser recognizes constructs such as "cache_store.."
in the .cfg file and  calls the appropriate  methods  of the
abstractization layer (core), which in turn calls the method of the
registered cache system(module).

    In other words  you need to modify the parser to recognize
"cache_increment" and "cache_decrement". If you choose this way you must
also create appropriate methods in the localcache module or at least
place warnings that they are not implemented.

    There is however a different approach. You can export the 2
functions as you did, but you need to manually search for the server and
call the library increment function. Of course the functions will look a
little different. They will look like this:

int cache_increment (struct sip_msg* msg, char* str1,char * str2 )
{
    //...some code to find the appropriate handle in "servers" list
    // you should use fix-up functions if you know how

    //call the increment  method.

    return 1; // or -1 on error
}

Hope it helps.

-- 
Andrei Dragus
www.voice-system.ro





More information about the Devel mailing list