如何使用redis提高代码的性能

时间:2017-04-28 05:21:16

标签: vb.net stackexchange.redis

我在我的机器上安装了Redis(Windows 7 64位),然后编写以下代码

Private Sub ReadDta()
    Dim Conn As ConnectionMultiplexer = ConnectionMultiplexer.Connect("localhost")
    Dim redis As IDatabase = Conn.GetDatabase

    Dim lObjConnection As New SqlConnection(gStrConnectionString)
    lObjConnection.Open()

    Dim lStrQuery = "SELECT * FROM [dbo].[AggregarTest_2M]"

    Dim SqlCommand As SqlCommand = New SqlCommand(lStrQuery, lObjConnection)
    Dim lObjDataReader As SqlDataReader = SqlCommand.ExecuteReader()

    If lObjDataReader IsNot Nothing Then

        For cnt As Integer = 0 To 2000000 - 1
            lObjDataReader.Read()

            'Loop throug each column (Total columns: 20) to create redis list against 'each column and save its value
            For count = 1 To 20 - 1               
                Dim colName = lObjDataReader.GetName(count)                   
                Dim val = lObjDataReader(colName)

                redis.ListRightPush(colName.ToString, val.ToString)
            Next
        Next
    End If
End Sub

这需要花费太多时间来执行。

以下是我的Redis安装

Redis Installation

我是否在Redis安装或我的代码中遗漏了一些东西

0 个答案:

没有答案