If I try to summarise it, the language uses lazy evaluation on everything by default. Thus, you may have an array of some number of elements that I want to perist. However, I don't know anything about the contents of those elements, because the functions that compute them haven't even been executed yet.
This means that even if I wanted to, there is no way to find out how many bytes the serialised form of this array is.
Currently, I serialise the data into a buffer, and then send that buffer to Valkey in a single SET call.
This is jot ideal, because if I could write the data directly to Valkey, there would be zero copying involved. Also, there would be no need to hold on to an array in menory that could get pretty large.
I have not found a way to do this in Valkey, since wire protocol requires a size prefix that tells Valkey how many bytes it need to read.
And even if this existed, I'd need one more feature. Since in my ideal solution, the write to Valkey starts before the code that generates this data has even finished evaluating, so there also needs to be a way to abort the Valkey write if the evaluation yields an error.
Although the last one can probably be solved using transactions.