Unless you design a mechanism to save the data to disk, any changes will be lost. A wrapper script in init would be a good starting point.
It's important to realize that it's difficult to use a mechanism like this and design it to be infallible. If the server suffered a total crash or complete loss of power, you would have data loss. You would have to design your backups to compensate for this and decide what level of risk you are comfortable with.
I would probably have a replication slave writing to disk as a means to have a copy of the data in case of failure.
I read too quickly, I thought you were talking about storing the database in tmpfs. pjz's answer covers storing MySQL temporary data on a tmpfs /tmp filesystem. It's okay unless you replicate.