![]() |
Fun API Documentation 0.42.1
The programming language that makes you have fun!
|
Hiredis handle registry and reply mapping helpers for the Fun VM. More...
Go to the source code of this file.
Hiredis handle registry and reply mapping helpers for the Fun VM.
This translation unit provides two small building blocks used by the Redis opcodes (implemented under src/vm/redis/*.c) and included from src/vm.c:
1) A process-local registry that assigns monotonically increasing positive integer identifiers to hiredis connection pointers (redisContext*). VM opcodes pass integer ids on the stack instead of raw pointers, keeping the bytecode portable and preventing accidental misuse of pointers.
2) Utilities to convert hiredis reply objects (redisReply) into Fun VM Value instances, recursively mapping arrays and supporting basic numeric and string types.
The code is compiled only when the CMake option FUN_WITH_REDIS is enabled (i.e., the preprocessor symbol FUN_WITH_REDIS is defined). When disabled, this file contributes no symbols and the corresponding opcodes are compiled into stubs that return neutral values.
Functions here perform basic validation/allocations only. Allocation failures return NULL (for lookups/additions) or are silently ignored (for deletions of non-existent ids). No hiredis API calls are made here, so no hiredis error codes are produced by this module itself.
The registry is a simple singly-linked list with no synchronization. It is NOT thread-safe. If the VM uses Redis from multiple threads, the caller must provide external synchronization around calls to these helpers.
Definition in file redis.c.