UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'K1teSweoWAEUPY0cDTMShm/hLQnzhMmvqlC1mvW+Txo=' 
WHERE 
  key_id = '606e7ea6260615bdf55e50f878d61173094679640ce7c798c75de7666bd6d8a9' 
  AND (
    token = 'K1teSweoWAEUPY0cDTMShm/hLQnzhMmvqlC1mvW+Txo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038