Forum Discussion
qqdixf5_74186
Nimbostratus
May 27, 2009v10 class feature
We are migrating our iRules to v10 and need to change the way we access datagroups. First, thank you for the detailed explanation about the new class feature(http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=2309).
So now we have two approaches to get the data. We can use the various class commands to access the elements within a datagroup directly , or get the data back as a list and use tcl list commands. Which approach do you recommend? Is one better than the other?
Thanks!
- JRahm
Admin
I'd turn timing on and find out which was most efficient, and go with that version. I would think direct access would be quicker than multiple operations, but testing will prove that out. - qqdixf5_74186
Nimbostratus
Have a question on the new [class] commands. - spark_86682Historic F5 AccountI basically agree with citizen_elah. Accessing the data via the class command is almost certainly going to be faster than first turning it into a list and then accessing the list. You could use the timing commands if you want to check for sure.
- spark_86682Historic F5 AccountGiven the way the class command currently operates, no. If you look carefully, the vipsForA variable is a list with 3 elements. However, the vipsForB variable is a string with two words in it. When you do an llength of it, it treats it as a list, and gives you the correct answer that there are two items there. (I'm being a little fuzzy here, since Tcl doesn't have strictly typed variables)
class myDataGroup { {"{vip1_a 123.4.5.6}"}{} {"{vip2_a 123.4.5.7}"}{} {"{vip3_a 123.4.5.8}"}{} {"{vip1_b 123.4.5.9}"}{} }
set resultA [class names -nocase myDataGroup *_a*] set resultB [class names -nocase myDataGroup *_b*] log local0. "resultA: $resultA countA: [llength $resultA]" log local0. "resultB: $resultB countB: [llength $resultB]"
resultA: {{vip1_a 123.4.5.6}} {{vip2_a 123.4.5.7}} {{vip3_a 123.4.5.8}} countA: 3 resultB: {vip1_b 123.4.5.9} countB: 1
set result [class names -nocase myDataGroup *_a*] if { $result contains "{" } { set length [llength $result] } else { set length 1 } log local0. "result: $result length: $length"
- qqdixf5_74186
Nimbostratus
First solution works better in my case. Thanks a lot, Spark!
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