Forum Discussion
smp_86112
Cirrostratus
May 04, 2010v10 - local vs. global vars
Trying to wrap my mind around how this variable scope works. I have a simple iRule I'm testing with:
when HTTP_REQUEST {
global client_local [TCP::local_port clientside]
if...
smp_86112
Cirrostratus
May 05, 2010Ahh, Jason that was a fantastic reference. That video cleared it all up, and I was able to confirm the behavior I was expecting.
Having watched that video, I think my statement about the three variables is spot-on. My feeling is that the doc I've read left me with the impression that there are three distinct types of variables - local, global, and static, when there are really just two - local and global. The trick for helping me understand is that global variables are subdivided into two types - CMP-compatible and non-CMP-compatible.
There were lots of takeaways from that video, but here are a couple specifically related to the questions I posed in this thread:
1. local variables set var "value" are CMP-compatible, can be defined in any event, and are referenced like $var.
2. Non-static global variables are not CMP-compatible, are defined like set ::var "value", demotes all virtual servers with an irule referencing to a single CPU, and are referenced like $::var
3. Static global variables are CMP-compatible, can only be defined in the RULE_INIT event, are defined like set static::var "value", and can be referenced by any iRule like $static::var.
Hopefully this helps others out. Thanks a lot for your thoughts guys.
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