Timeout value for cache_store function and timeout refreshing

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Timeout value for cache_store function and timeout refreshing

Andreas Westermaier
Hi,

I'm currently using 'cache_store()' to store channel limits for customers in memory to avoid the need of especially fetching it (either from radius, or from db).

Channel limit information comes in via SIP-AVP from radius on each register ('radius_www_authorize()') and on each invite ('radius_proxy_authorize()').

So after a successfull 'radius_proxy_authorize()' I currently do

if (is_avp_set("$avp(s:chanlimit)/n") && avp_check("$avp(s:chanlimit)", "gt/i:0")) {
        cache_store("local", "chanlimit_$au@$ar", "$avp(s:chanlimit)", 86400);
}

This stores the information for a whole day. But I think this could be tweaked if it would be possible to set the timeout for cache expiry to the value of the registration expiry. E.g. by using "$(hdr(Expires){s.int})" as the last parameter for 'cache_store()'.

Q1: Is there a reason why the function currently does not support the variable "$(hdr(Expires){s.int})" for the timeout value or is it just not yet implemented?

Allowing variables for timeout, the channel limit information would be available as long as the registration for a user will be valid and expires when the registration does. Of course, on each renewal of the registration also the memcache variable has to be refreshed.

Q2: Can the timeout for a memcache variable currently refreshed just by calling 'cache_store()' a second time, after the first execution and before expiration or is it necessary to firstly remove the variable from cache and insert it again for the timer to get reset?


Regards,
Andreas


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Timeout value for cache_store function and timeout refreshing

Anca Vamanu-2
Hi Andreas,

Andreas Westermaier wrote:

> Hi,
>
> I'm currently using 'cache_store()' to store channel limits for customers in memory to avoid the need of especially fetching it (either from radius, or from db).
>
> Channel limit information comes in via SIP-AVP from radius on each register ('radius_www_authorize()') and on each invite ('radius_proxy_authorize()').
>
> So after a successfull 'radius_proxy_authorize()' I currently do
>
> if (is_avp_set("$avp(s:chanlimit)/n") && avp_check("$avp(s:chanlimit)", "gt/i:0")) {
> cache_store("local", "chanlimit_$au@$ar", "$avp(s:chanlimit)", 86400);
> }
>
> This stores the information for a whole day. But I think this could be tweaked if it would be possible to set the timeout for cache expiry to the value of the registration expiry. E.g. by using "$(hdr(Expires){s.int})" as the last parameter for 'cache_store()'.
>
> Q1: Is there a reason why the function currently does not support the variable "$(hdr(Expires){s.int})" for the timeout value or is it just not yet implemented?
>
>  
No, there is no reason not to support variable for expires argument and
it is a good idea to have it. I will implement it after the release.
> Allowing variables for timeout, the channel limit information would be available as long as the registration for a user will be valid and expires when the registration does. Of course, on each renewal of the registration also the memcache variable has to be refreshed.
>
> Q2: Can the timeout for a memcache variable currently refreshed just by calling 'cache_store()' a second time, after the first execution and before expiration or is it necessary to firstly remove the variable from cache and insert it again for the timer to get reset?
>
>  
Yes, you can refresh the expires by calling cache_store again. The
implementation is such that a store for the same label rewrites the old
value.

regards,
Anca

> Regards,
> Andreas
>
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>  


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users