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

Abhinav Jha virolord at gmail.com
Tue Feb 23 08:15:49 CET 2010


Thanks Andrei,

This helped a lot. I chose the first method (modified the parser to
recognize cache_increment and cache_decrement methods) and now I have
working atomic cached_increment and cached_decrement methods in memcached
module as well :)

Abhinav

On Mon, Feb 22, 2010 at 4:01 PM, Andrei Dragus <adragus at opensips.org> wrote:

> 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
>
>
>
> _______________________________________________
> Devel mailing list
> Devel at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.opensips.org/pipermail/devel/attachments/20100223/c377f026/attachment-0001.htm 


More information about the Devel mailing list