How can I refresh the macOS dictionary? Consider the following workflow:

Open TextEdit.
Type a word that's not in the dictionary.
Right-click on that word and select 'Learn Spelling'.
Observe the squiggly underline disappears, as the word is now recognised.
Observe the word is added to the ~/Spelling/LocalDictionary file.
Quit TextEdit.
Remove the word from the ~/Spelling/LocalDictionary file.
Reopen TextEdit.
Type the same word again.
Observe it is still recognised (not squiggly-underlined), despite no longer being in the local dictionary.

It seems the problem here is that there is some sort of cache maintained by macOS that is not refreshed. If I right-click on the word in TextEdit to remove it from the local dictionary instead of editing the file, it is indeed no longer recognised; i.e., this appears to update the cache.
Is there any way I can manually refresh the cache of local dictionary words?
I figured this out myself in the end. One needs to relaunch the com.apple.applespell service (from the command line).
launchctl stop com.apple.applespell
launchctl start com.apple.applespell