Forum Discussion
dragonflymr
Cirrostratus
Dec 21, 2015table and sort order
Hi,
From my simple test it seems that keys are listed (for example in foreach loop) in the order they were created so key created first is listed as last and key created as last first (at least wit...
Kai_Wilke
MVP
Dec 21, 2015Hi Piotr,
there is always a little danger if someone tries to use creative codings and explores undocumented stuff. So be prepared that this behavior may change with later updates...
But to answer your question....
I guess your code can be improved by using the [lrange] command to filter the relevant key names before passing the retrived [list] to the [foreach] loop. But I haven't tested out the performance differences...
set keys_current [table keys -subtable master -count]
set keys_to_remove 10
foreach key [lrange [table keys -subtable master] [expr { $keys_current - $keys_to_remove + 1 }] $keys_current] {
table delete -subtable master $key
}
Cheers, Kai
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
