UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'aGS63tuX8lOy+1rUv+5zp/40/5y0SvYm3m9eDq1Il0I=' 
WHERE 
  key_id = '8e03c964922d3aa6543b2768a6acab3b4657a62cf64166485323fccce837a1c2' 
  AND (
    token = 'aGS63tuX8lOy+1rUv+5zp/40/5y0SvYm3m9eDq1Il0I=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028