Persist iRule based on source address

Hi

Hopefully this is an easy question. I have a HTTPS VIP with two pool members and four possible sources (A,B,C,D). I need to create an irule that uses a persist timeout of say 30 seconds when the source is A&B and a timeout of 1800 seconds when the source is C&D? in other words a different timeout for the same VIP based on the source address?

Thanks in advance

Gavster78

Here is perhaps one way to do this: create a Universal persistence profile, apply the following iRule, and set Timeout to Indefinite. Then apply this persistence profile to your virtual server:

when CLIENT_ACCEPTED {
    if { [persist lookup source_addr [IP::client_addr]] ne "" } {
        persist source_addr [IP::client_addr]
    } 
}
when SERVER_CONNECTED {
    if { [persist lookup source_addr [IP::client_addr]] equals "" } {
        switch [IP::client_addr] {
            "10.80.0.1" { persist add source_addr [IP::client_addr] 30 }
            "10.80.0.2" { persist add source_addr [IP::client_addr] 30 }
            "10.70.0.1" { persist add source_addr [IP::client_addr] 1800 }
            "10.70.0.2" { persist add source_addr [IP::client_addr] 1800 }
        }
    }   
}