UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'K7aZDWCbGaVq1kelYCOMRX+xiypZD0IuchTIM+AZPRg=' 
WHERE 
  key_id = '7ed7e560af56d043fbb58387d5554d184ff838394a87eaabddf1c31651d3d9ff' 
  AND (
    token = 'K7aZDWCbGaVq1kelYCOMRX+xiypZD0IuchTIM+AZPRg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00039