xLeaves
22-07-2019, 14:33
This library is still very basic, exporting all the functions of the hiredis library and encapsulating some commonly used functions.
In general, it works well in the ThinBasic environment.
Declare Function Redis_Connect Lib "hiredis.dll" Alias "LzBot_Redis_Connect" (ByVal ip As ZString, ByVal port As Long) As Long
Declare Function Redis_ConnectWithTimeout Lib "hiredis.dll" Alias "LzBot_Redis_ConnectWithTimeout" (ByVal ip As ZString, ByVal port As Long, ByVal ms As Long) As Long
Declare Sub Redis_Free Lib "hiredis.dll" Alias "redisFree" (ByVal c As Long)
Declare Function Redis_LastError Lib "hiredis.dll" Alias "LzBot_Redis_LastError" () As String
Declare Function Redis_Ping Lib "hiredis.dll" Alias "LzBot_Redis_Ping" (ByVal c As Long, ByVal s As ZString) As String
Declare Function Redis_Set Lib "hiredis.dll" Alias "LzBot_Redis_Set" (ByVal c As Long, ByVal k As ZString, ByVal v As ZString) As String
Declare Function Redis_SetBin Lib "hiredis.dll" Alias "LzBot_Redis_SetBin" (ByVal c As Long, ByVal k As ZString, ByVal kl As Long, ByVal v As ZString, ByVal vl As Long) As String
Declare Function Redis_Get Lib "hiredis.dll" Alias "LzBot_Redis_Get" (ByVal c As Long, ByVal k As ZString) As String
Declare Function Redis_Append Lib "hiredis.dll" Alias "LzBot_Redis_Append" (ByVal c As Long, ByVal k As ZString, ByVal v As ZString) As String
Declare Sub Redis_Del Lib "hiredis.dll" Alias "LzBot_Redis_Del" (ByVal c As Long, ByVal k As ZString)
Declare Sub Redis_Rename Lib "hiredis.dll" Alias "LzBot_Redis_Rename" (ByVal c As Long, ByVal k As ZString, ByVal nk As ZString)
Declare Function Redis_Exists Lib "hiredis.dll" Alias "LzBot_Redis_Exists" (ByVal c As Long, ByVal k As ZString) As Long
Declare Function Redis_Incr Lib "hiredis.dll" Alias "LzBot_Redis_Incr" (ByVal c As Long, ByVal k As ZString) As Int64
Declare Function Redis_Incrby Lib "hiredis.dll" Alias "LzBot_Redis_Incrby" (ByVal c As Long, ByVal k As ZString, ByVal v As Long) As Int64
Declare Function Redis_Decr Lib "hiredis.dll" Alias "LzBot_Redis_Decr" (ByVal c As Long, ByVal k As ZString) As Int64
Declare Function Redis_Decrby Lib "hiredis.dll" Alias "LzBot_Redis_Decrby" (ByVal c As Long, ByVal k As ZString, ByVal v As Long) As Int64
Declare Function Redis_Type Lib "hiredis.dll" Alias "LzBot_Redis_Type" (ByVal c As Long, ByVal s As ZString) As String
Declare Function Redis_Info Lib "hiredis.dll" Alias "LzBot_Redis_Info" (ByVal c As Long, ByVal s As ZString) As String
Declare Function Redis_Keys Lib "hiredis.dll" Alias "LzBot_Redis_Keys" (ByVal c As Long, ByVal s As ZString) As String
Dim c as long = redis_Connect("127.0.0.1", 6379)
msgbox Redis_Ping(c, "asd")
Redis_Set(c, "key", 10)
msgbox Redis_Get(c, "key")
for i as integer = 1 to 10
traceprint Redis_Incr(c, "key")
next
MsgBox Redis_Keys(c, "*")
The above code can be copied to ThinBasic to work.
For this you need to put this dll in the same directory as the script.
9973
In general, it works well in the ThinBasic environment.
Declare Function Redis_Connect Lib "hiredis.dll" Alias "LzBot_Redis_Connect" (ByVal ip As ZString, ByVal port As Long) As Long
Declare Function Redis_ConnectWithTimeout Lib "hiredis.dll" Alias "LzBot_Redis_ConnectWithTimeout" (ByVal ip As ZString, ByVal port As Long, ByVal ms As Long) As Long
Declare Sub Redis_Free Lib "hiredis.dll" Alias "redisFree" (ByVal c As Long)
Declare Function Redis_LastError Lib "hiredis.dll" Alias "LzBot_Redis_LastError" () As String
Declare Function Redis_Ping Lib "hiredis.dll" Alias "LzBot_Redis_Ping" (ByVal c As Long, ByVal s As ZString) As String
Declare Function Redis_Set Lib "hiredis.dll" Alias "LzBot_Redis_Set" (ByVal c As Long, ByVal k As ZString, ByVal v As ZString) As String
Declare Function Redis_SetBin Lib "hiredis.dll" Alias "LzBot_Redis_SetBin" (ByVal c As Long, ByVal k As ZString, ByVal kl As Long, ByVal v As ZString, ByVal vl As Long) As String
Declare Function Redis_Get Lib "hiredis.dll" Alias "LzBot_Redis_Get" (ByVal c As Long, ByVal k As ZString) As String
Declare Function Redis_Append Lib "hiredis.dll" Alias "LzBot_Redis_Append" (ByVal c As Long, ByVal k As ZString, ByVal v As ZString) As String
Declare Sub Redis_Del Lib "hiredis.dll" Alias "LzBot_Redis_Del" (ByVal c As Long, ByVal k As ZString)
Declare Sub Redis_Rename Lib "hiredis.dll" Alias "LzBot_Redis_Rename" (ByVal c As Long, ByVal k As ZString, ByVal nk As ZString)
Declare Function Redis_Exists Lib "hiredis.dll" Alias "LzBot_Redis_Exists" (ByVal c As Long, ByVal k As ZString) As Long
Declare Function Redis_Incr Lib "hiredis.dll" Alias "LzBot_Redis_Incr" (ByVal c As Long, ByVal k As ZString) As Int64
Declare Function Redis_Incrby Lib "hiredis.dll" Alias "LzBot_Redis_Incrby" (ByVal c As Long, ByVal k As ZString, ByVal v As Long) As Int64
Declare Function Redis_Decr Lib "hiredis.dll" Alias "LzBot_Redis_Decr" (ByVal c As Long, ByVal k As ZString) As Int64
Declare Function Redis_Decrby Lib "hiredis.dll" Alias "LzBot_Redis_Decrby" (ByVal c As Long, ByVal k As ZString, ByVal v As Long) As Int64
Declare Function Redis_Type Lib "hiredis.dll" Alias "LzBot_Redis_Type" (ByVal c As Long, ByVal s As ZString) As String
Declare Function Redis_Info Lib "hiredis.dll" Alias "LzBot_Redis_Info" (ByVal c As Long, ByVal s As ZString) As String
Declare Function Redis_Keys Lib "hiredis.dll" Alias "LzBot_Redis_Keys" (ByVal c As Long, ByVal s As ZString) As String
Dim c as long = redis_Connect("127.0.0.1", 6379)
msgbox Redis_Ping(c, "asd")
Redis_Set(c, "key", 10)
msgbox Redis_Get(c, "key")
for i as integer = 1 to 10
traceprint Redis_Incr(c, "key")
next
MsgBox Redis_Keys(c, "*")
The above code can be copied to ThinBasic to work.
For this you need to put this dll in the same directory as the script.
9973