Hiredis Platform Interface
Description
<EsHiredisPI> is the Platform Interface (PI) sub-application that provides the bridge to the native hiredis C library. Its role is twofold:
-
It provides a direct Foreign Function Interface (FFI) to the hiredis C library's powerful and efficient parsing routines.
-
It contains the pure Smalltalk connection context, <EsHiredisSciSocketContext>, which manages network communication using the <SocketCommunicationsInterface> framework.
This layered approach encapsulates all low-level interaction, allowing the high-level <EsRedisApp> to remain agnostic of both the C implementation details and the underlying socket communication mechanism.
Key Components
Connection Context
<EsHiredisSciSocketContext>: A pure Smalltalk object that manages the connection lifecycle. It uses an <SciSocket> for network I/O and orchestrates the sending of commands and the feeding of replies to the hiredis parser.
FFI Constants
EsHiredisConstants: A pool dictionary that defines all necessary C constants from the hiredis.h header file, such as reply types (e.g., REDIS_REPLY_STRING) and connection flags (e.g., REDIS_CONNECTED).
FFI Function Mappings
EsHiredisPlatformFunctions: A pool dictionary that maps C functions from the hiredis library to Smalltalk PlatformFunction objects. This enables direct calls into the native library for functions like redisConnect, redisCommandArgv, and freeReplyObject.
C Structure Wrappers
<OSHiredisStructure> and its subclasses (notably <OSHiredisReader> and <OSHiredisReply>): A hierarchy of classes that provide a direct memory mapping to the C structs used by the hiredis parser. These are essential for receiving structured data back from the C library's parsing functions.
FFI Call Strategy
<EsHiredisCallEngine> and its subclasses: An abstraction that defines the strategy for how FFI calls are executed, supporting both direct synchronous calls and non-blocking asynchronous calls.
Class Methods
None
Instance Methods
None
Last modified date: 01/22/2026