Forum Discussion
Charles_Harris
Feb 12, 2007Nimbostratus
Global Variables in RULE_INIT
Hi,
This is a little strange, but I can't get a global variable defined within an iRule.
Have I got Monday syndrome or does this look odd for example:
when RULE_INIT{ ...
Feb 12, 2007
Just to chime in here for a minute. Variables can be shared across a connection without being in the global scope (ie, using "::"). RULE_INIT is a special rule that is only run at initialization time and not for each connection. So, any local variables created there will not be available across other events. Any variables you want set in RULE_INIT make sure that you use the global scope.
Just keep in mind that if you are modifying global variables in different connections, they will be modified for all connections. One common mistake it to put SSL certificate info in a global variable and then trying to access it in another event. Each new connection will overwrite that global variable and will likely yield unwanted results.
Also, global variables do use up memory and are not ever freed unless you explicitly "unset" them. Connection variables are freed when the connection closes so there is a built-in garbage collection.
-Joe
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects