pub fn parse_memory(value: &[u8]) -> Option<u64>Expand description
Read a byte count the way CONFIG SET maxmemory reads one.
This is Redis’s memtoull. Digits, then an optional unit that is not case
sensitive: nothing or b is bytes, k is a thousand and kb is a kibibyte,
and the same pairing again for m and g. The two spellings meaning
different numbers is a trap and it is Redis’s trap, so it is repeated here
rather than tidied up.
A unit that overflows clamps rather than failing, which is upstream’s
ULLONG_MAX arm. There is no sign: a leading minus is refused before the
digits are read, so maxmemory -1 is not a very large number.
Public because yodb serve takes the same limits on the command line that
CONFIG SET takes at runtime, and a server that accepts 100mb from one and
not the other, or reads it as a different number, is a server that gets
misconfigured. One parser, one answer.