global variables

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

global variables

Jan D.
Another day, another question:

I like to declare some variables at the beginning of my script and use this at several places, the variables must be known till restart.

something like ie:

$my_eth0_interface = "89.1.2.3";
$my_eth1_interface = "10.0.1.2";
$my_default_timeout = 100;
etc etc.

I was looking at cache_store() but don't know what to use best in this case.

Any advise how to accomplish this?

Gr.

Jan
Reply | Threaded
Open this post in threaded view
|

Re: global variables

Vlad Paiu
Hello,

If you want to accomplish this, you can use the localcache module. In
startup_route, initialize all of your needed 'constants' and store them
with no expiry time ( cache_store ), and when you want to use them later
on, just make a call to cache_fetch.

Regards

Vlad Paiu
OpenSIPS Developer
http://www.opensips-solutions.com


On 03/20/2012 05:38 PM, Jan D. wrote:

> Another day, another question:
>
> I like to declare some variables at the beginning of my script and use this
> at several places, the variables must be known till restart.
>
> something like ie:
>
> $my_eth0_interface = "89.1.2.3";
> $my_eth1_interface = "10.0.1.2";
> $my_default_timeout = 100;
> etc etc.
>
> I was looking at cache_store() but don't know what to use best in this case.
>
> Any advise how to accomplish this?
>
> Gr.
>
> Jan
>
> --
> View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/global-variables-tp7389514p7389514.html
> Sent from the OpenSIPS - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: global variables

Nick-3
In reply to this post by Jan D.
Use m4 macro processor.

--
Nick


2012/3/20 Jan D. <[hidden email]>
Another day, another question:

I like to declare some variables at the beginning of my script and use this
at several places, the variables must be known till restart.

something like ie:

$my_eth0_interface = "89.1.2.3";
$my_eth1_interface = "10.0.1.2";
$my_default_timeout = 100;
etc etc.

I was looking at cache_store() but don't know what to use best in this case.

Any advise how to accomplish this?

Gr.

Jan

--
View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/global-variables-tp7389514p7389514.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.

_______________________________________________
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