use a struct for cached keys, only set the UTF8 flag if needed