cRedisClient - Redis Client
Overview
cRedisClient is a simple and easy-to-use Redis database client written in VB6/VBA. It supports the Redis RESP protocol and provides common Redis command interfaces, including connection management, basic operations, data structure operations, and transactions.
Features
- Supports basic Redis commands (GET, SET, DEL, EXISTS, KEYS, etc.)
- Supports multiple data structures: String, Hash, List, Set, Sorted Set
- Supports pipeline mode
- Supports transaction mode
- Automatic reconnection mechanism
- Supports Redis password authentication
- Supports multiple database switching
- Synchronous operations, simple and easy to use
Documentation
- Connection Management - Connect and disconnect from Redis server
- Basic Commands - Authentication, database selection, information query, etc.
- String Operations - Key-value operations
- Hash Operations - Hash table operations
- List Operations - List operations
- Set Operations - Set operations
- Sorted Set Operations - Sorted set operations
- Transaction Operations - Transaction management
- Complete Examples - Comprehensive usage examples
Properties
| Property | Type | Description |
|---|---|---|
| Host | String | Get Redis server address |
| Port | Long | Get Redis server port |
| Connected | Boolean | Get connection status |
| DbIndex | Long | Get or set current database index (0-15) |
| Timeout | Double | Get or set timeout in seconds |
| InTransaction | Boolean | Get if in transaction |
| InPipeline | Boolean | Get if in pipeline mode |
| LastError | String | Get last error message |
| Socket | cWinsock | Get underlying Socket object |
Notes
- Connection Management: Remember to call
DisConnectmethod to release connection when done - Error Handling: Check connection status and
LastErrorproperty before and after operations - Timeout Settings: Set
Timeoutproperty appropriately based on network environment - Data Types: All values in Redis are stored as strings, numeric operations require conversion
- Transaction Safety: Commands in transactions are not executed until
ExecorDiscardis called - Batch Operations: Use
MGet,MSetand other batch operations to improve performance - Resource Release: Set object to
Nothingwhen no longer in use
Dependencies
cWinsock- Socket communication componentToolsUtf8- UTF-8 encoding/decoding toolScripting.Dictionary- ForHGetAllto return dictionary object
Quick Start
vb
Dim oRedis As New cRedisClient
' Connect to local Redis server
If oRedis.Connect() Then
Debug.Print "Connected successfully!"
' Set key-value
oRedis.Set_ "name", "Zhang San"
' Get value
Debug.Print "Name: " & oRedis.Get_("name")
' Disconnect
oRedis.DisConnect
Else
Debug.Print "Connection failed: " & oRedis.LastError
End IfLicense
Please refer to the main project documentation for license information.