UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Gi5VygW201PwDwdfrUNTiCSDaS78ZCdKexHD45L0E40=' 
WHERE 
  key_id = 'd040442f294b2f08b22433f3904ef166d513a7e0b85ed882ca3d185f48e956e9' 
  AND (
    token = 'Gi5VygW201PwDwdfrUNTiCSDaS78ZCdKexHD45L0E40=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00041