UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'T6e1FSO5iv23ZYelH4tVKm3/dWues3oMoykz8+xGqO8=' 
WHERE 
  key_id = '713d97bb76930527415d8b5256797611524556eb1d9b36ad3c534c3b3a893947' 
  AND (
    token = 'T6e1FSO5iv23ZYelH4tVKm3/dWues3oMoykz8+xGqO8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00029