Forum Discussion
Mark_Moseley
Nimbostratus
Nov 14, 2005Predefining variables and how iRules work
Hi. This is a two-parter, neither of which I can find answers for but might be using the wrong search terms (in which case, my apologies).
1) Is it possible to pre-define variables in iRules...
Nov 14, 2005
As citizen_elah mentioned, in most cases you can create data groups (string, address, etc). As long as the list is static, then this should work out for you. All code must exist within an event construct.
But, for your situation, we have a special event mainly desiged for this purpose.
the RULE_INIT event.
when RULE_INIT {
set ::global_var "some value"
}
This event is raised once at load time of the rule.
This leads into question 2. Rules are compiled into byte code at load time. They are not interpreted from source on each processing of the rule.
Creating a slew of variables in events is not advised if they are static in nature as that takes memory allocations on each connection which can be very costly. An external data group, or a global variable will only incur a single memory allocation for them. Keep in mind though that all connections will have access to these variables so try to avoid modifications of the global vars to avoid contentions between the different connections.
-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
