UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Q0sd1hvf7Cs0N7PbI41nAZss466IOPEWpX7PTFCslfk=' 
WHERE 
  key_id = '1f52425659812809fece88b18bdc049a70de063358aa4b6cc14b1fa245555962' 
  AND (
    token = 'Q0sd1hvf7Cs0N7PbI41nAZss466IOPEWpX7PTFCslfk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032