UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'O/FfB2alnhkWaHMkYnS6kKgqA3XehLMukgcnxTn+5z8=' 
WHERE 
  key_id = '959b45e0a9928c223c642991162dd20b5893f98475e239c8e4cd4cb01106cb2c' 
  AND (
    token = 'O/FfB2alnhkWaHMkYnS6kKgqA3XehLMukgcnxTn+5z8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035