store package provides the core key-value storage functionality for ValKeyper, including support for expiration, replication, transactions, and Redis streams.
KVStore
The main store struct that manages all data and server operations.Server configuration and replication information
Internal key-value storage map
Manages key expiration channels
Channel for replication acknowledgments
Tracks if write operations have been processed
Channel for stream entry notifications
Storage for Redis stream entries by stream key
New
Creates a new KVStore instance with default configuration.A new KVStore instance configured as master on port 6379
Set
Stores a key-value pair with optional expiration.The key to store
The value to store
Expiration time in milliseconds. Use -1 for no expiration
HandleConnection
Handles incoming client connections and processes commands.The connection wrapper containing the net.Conn and transaction state
RESP protocol parser for reading commands
processCommand
Processes individual Redis commands and returns the response.Array of command and arguments
Pointer to the connection for transaction state management
RESP-encoded response to send to the client
PING,ECHO- Basic protocol commandsSET,GET,DEL- Key-value operationsINCR- Atomic incrementKEYS,TYPE- Key introspectionCONFIG,INFO- Server informationXADD,XRANGE,XREAD- Stream operationsMULTI,EXEC,DISCARD- TransactionsREPLCONF,PSYNC,WAIT- Replication
LoadFromRDB
Loads key-value pairs and expiration data from an RDB snapshot.Parsed RDB file structure
HandleReplication
Establishes replication connection to a master server.Connection
Wraps a network connection with transaction state.The underlying network connection
Whether a MULTI transaction has been started
Queue of commands to execute on EXEC
Info
Server configuration and replication metadata.Server role: “master” or “slave”
IP address of the master (slave only)
Port of the master (slave only)
Master replication ID
Current replication offset
Connection to master server (slave only)
Connected slave connections (master only)
Server listening port
Command-line configuration flags
StreamEntry
Represents a single entry in a Redis stream.Stream entry ID in format “timestamp-sequence”
Field-value pairs for this stream entry