is to filter the content submitted by the user for sensitive words. If the sensitive words are stored in the database, write a sensitive word filtering function (query the sensitive words from the database).
If the user submits content, it will be called This function means that the database must be queried every time, so the design feels unreasonable.
I would like to ask how to design the sensitive word filtering more rationally. Is it okay to write the sensitive words into the configuration file of the project and not store them in the database?
Yes, you can separate the inscriptions by separators and save them into a text file, or directly use a script to generate json and save it into the file. When reading, parse and read directly.
There is also a faster way. If there are not too many inscriptions (only a few hundred to 2 or 3 thousand), you can directly save them in a configuration file in the form of an array and return an array. The array is retrieved directly each time.